39 lines
1,012 B
PHP
39 lines
1,012 B
PHP
|
<?php
|
||
|
|
||
|
define('SEARCH_STOPS',1);
|
||
|
define('SEARCH_LINES',2);
|
||
|
define('SEARCH_ALL',SEARCH_STOPS|SEARCH_LINES);
|
||
|
|
||
|
class SearchQuery {
|
||
|
|
||
|
private $originalQueryString;
|
||
|
private $queryString;
|
||
|
private $searchForTypes;
|
||
|
|
||
|
public function __construct ($queryString, $searchForTypes=SEARCH_ALL) {
|
||
|
|
||
|
if (!is_string($queryString)) {
|
||
|
throw new InvalidArgumentException('$queryString must be a string');
|
||
|
}
|
||
|
if (!is_int($searchForTypes)) {
|
||
|
throw new InvalidArgumentException('$searchForTypes must be an integer (a bitwise OR-combination of SEARCH_...)');
|
||
|
}
|
||
|
|
||
|
$this->originalQueryString = $queryString;
|
||
|
$this->queryString = rawurlencode(strtolower(str_replace(array('"', "'", '-', '.', '%'), ' ', $queryString)));
|
||
|
$this->searchForTypes = $searchForTypes;
|
||
|
|
||
|
}
|
||
|
//https://www.delijn.be/rise-api-search/search/lijnen/knokke/1
|
||
|
|
||
|
public function execute () {
|
||
|
|
||
|
$req = new ApiSearchRequest('search/haltes/' . $this->queryString . '/1');
|
||
|
return $req->exec();
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
?>
|