diff --git a/README.md b/README.md index ad510f1..11dc608 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A PHP API client for the SEMrush API. ## Supported actions: * domain_ranks -* domain_domain +* domain_domains * domain_rank * domain_rank_history * domain_organic diff --git a/src/Model/Request.php b/src/Model/Request.php index 121e81b..124b52d 100644 --- a/src/Model/Request.php +++ b/src/Model/Request.php @@ -228,20 +228,26 @@ protected function validateDomain($key, $domain) * @param string $key * @param string $domain * @throws InvalidOptionException + * + * Validates the format ||||||... */ protected function validateDomains($key, $domains) { $parts = explode('|', $domains); + if (count($parts) > 5 * 3) { // 5 domains max, each with 3 parts + throw new InvalidOptionException("[{$key}] contains too many domains"); + } + for ($i = 0; $i < count($parts); $i++) { switch ($i % 3) { case 0: - if (!in_array($parts[$i], ['+', '-', '/', '*'])) { + if (!in_array($parts[$i], ['+', '-', '/', '*'], true)) { throw new InvalidOptionException("[{$key}] contains an invalid sign [{ $parts[$i]}]"); } break; case 1: - if (!in_array($parts[$i], ['or', 'ad'])) { + if (!in_array($parts[$i], ['or', 'ad'], true)) { throw new InvalidOptionException("[{$key}] contains an invalid type - must be or or ad [{ $parts[$i]}]"); } break;