/**
  * Tests getRateReset method
  */
 public function testRateReset()
 {
     $response = new Response(200);
     $response->setHeader('X-Rate-Reset', '100');
     $client = new GenderizeClient();
     $client->setLastResponse($response);
     $this->assertEquals('100', $client->getRateReset());
 }
 /**
  * @param string|array $nameOrNames
  * @param string|null  $country
  * @param string|null  $language
  * @param int          $hydration
  *
  * @return Name|array
  *
  * @throws CountryNotValidException
  * @throws LanguageNotValidException
  */
 public function recognize($nameOrNames, $country = null, $language = null, $hydration = self::HYDRATE_OBJECT)
 {
     if ($country !== null && !isset($this->validCountries[strtoupper($country)])) {
         throw new CountryNotValidException(sprintf('Country %s is not valid', strtoupper($country)));
     }
     if ($language !== null && !isset($this->validLanguages[strtolower($language)])) {
         throw new LanguageNotValidException(sprintf('Language %s is not valid', strtolower($language)));
     }
     $query = ['name' => $nameOrNames];
     if ($this->apiKey !== null) {
         $query['apikey'] = $this->apiKey;
     }
     if ($country !== null) {
         $query['country_id'] = $country;
     }
     if ($language !== null) {
         $query['language_id'] = $language;
     }
     $data = $this->genderizeClient->genderize($query);
     if ($hydration == self::HYDRATE_OBJECT) {
         if (is_array($nameOrNames)) {
             $collection = [];
             foreach ($data as $nameData) {
                 $collection[] = Name::factory($nameData);
             }
             // multiple query
             return $collection;
         } else {
             // single query
             return Name::factory($data);
         }
     } else {
         // multiple or single query
         return $data;
     }
 }