Skip to content

Commit

Permalink
Feature/managing array (#11)
Browse files Browse the repository at this point in the history
* changing remove language method

* Adding key and removing array unique with getting array language values to be removed in case that it would be necessary

Co-authored-by: adsolis <[email protected]>
  • Loading branch information
alessandro811020 and adsolis authored Dec 13, 2022
1 parent 93e4970 commit e5b032e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Analyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ public function __construct($api_key, LoggerInterface $logger = null, ClientInte
* @param $language - ISO 631-1 two-letter language code
*/
public function addLanguage(String $language): void {
$this->languages[] = $language;
$this->languages[$language] = $language;
}

/**
* Remove support for a comment language
* @param String $language - ISO 631-1 two-letter language code
*/
public function removeLanguage(String $language): void {
if(in_array($language, $this->languages)) {
if((in_array($language, $this->languages, true)) !== false) {
unset($this->languages[$language]);
}
}
Expand Down Expand Up @@ -224,8 +224,7 @@ private function buildApiData(Comment $comment): array {
$api_data['comment'] = ['text' => $comment->getText()];

if(!empty($this->languages)) {
$this->languages = array_unique($this->languages);
$api_data['languages'] = $this->languages;
$api_data['languages'] = array_values($this->languages);
}

$api_data['requestedAttributes'] = [];
Expand Down

0 comments on commit e5b032e

Please sign in to comment.