Skip to content

Commit

Permalink
throw BadResponseException if query size is less than 3
Browse files Browse the repository at this point in the history
Error Message: "Search queries requires at least 3 characters"
  • Loading branch information
irfan-dahir committed Aug 17, 2019
1 parent 0bd04c7 commit a383282
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"brianium/paratest": "1.*",
"doctrine/collections": "^1.5",
"jakub-onderka/php-parallel-lint": "^1.0",
"jikan-me/jikan": "^2.8",
"jikan-me/jikan-fixtures": "dev-master",
"php-vcr/php-vcr": "~1.3.2",
"php-vcr/phpunit-testlistener-vcr": "^3.0",
Expand Down
7 changes: 7 additions & 0 deletions src/Request/Search/AnimeSearchRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jikan\Request\Search;

use Jikan\Exception\BadResponseException;
use Jikan\Request\RequestInterface;

/**
Expand Down Expand Up @@ -99,6 +100,12 @@ public function __construct(?string $query = null, int $page = 1)
$this->page = $page;

$this->query = $this->query ?? '';

$querySize = strlen($this->query);

if ($querySize > 0 & $querySize < 3) {
throw new BadResponseException('Search queries requires at least 3 characters');
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/Request/Search/CharacterSearchRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jikan\Request\Search;

use Jikan\Exception\BadResponseException;
use Jikan\Request\RequestInterface;

/**
Expand Down Expand Up @@ -44,6 +45,12 @@ public function __construct(?string $query = null, int $page = 1)
$this->page = $page;

$this->query = $this->query ?? '';

$querySize = strlen($this->query);

if ($querySize > 0 & $querySize < 3) {
throw new BadResponseException('Search queries requires at least 3 characters');
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/Request/Search/MangaSearchRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jikan\Request\Search;

use Jikan\Exception\BadResponseException;
use Jikan\Request\RequestInterface;

/**
Expand Down Expand Up @@ -94,6 +95,12 @@ public function __construct(?string $query = null, int $page = 1)
$this->page = $page;

$this->query = $this->query ?? '';

$querySize = strlen($this->query);

if ($querySize > 0 & $querySize < 3) {
throw new BadResponseException('Search queries requires at least 3 characters');
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/Request/Search/PersonSearchRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Jikan\Request\Search;

use Jikan\Exception\BadResponseException;
use Jikan\Request\RequestInterface;

/**
Expand Down Expand Up @@ -44,6 +45,12 @@ public function __construct(?string $query = null, int $page = 1)
$this->page = $page;

$this->query = $this->query ?? '';

$querySize = strlen($this->query);

if ($querySize > 0 & $querySize < 3) {
throw new BadResponseException('Search queries requires at least 3 characters');
}
}

/**
Expand Down

0 comments on commit a383282

Please sign in to comment.