search result in Request

This commit is contained in:
2023-04-18 17:12:06 +03:00
parent 4c85beb0ca
commit d2de940aa3
5 changed files with 74 additions and 18 deletions

View File

@ -35,6 +35,16 @@ class RequestService
*/
public bool $isLoad = false;
/**
* @var int
*/
public int $resultCount = 0;
/**
* @var array
*/
public array $resultProfiles = [];
/**
* @var array
*/
@ -235,9 +245,9 @@ class RequestService
/**
* @param int $searchDepth
* @return array|int
* @return RequestService
*/
public function search(int $searchDepth = 0)
public function search(int $searchDepth = 0):RequestService
{
$cards = $this->_search();
$res = [];
@ -254,14 +264,10 @@ class RequestService
$res = $this->checkLevel(false)->checkPosition(false)->setSkillsFullEntry(false)->useExcludePool()->_search();
}
if ($this->returnCount) {
if (is_array($res)) {
return $cards;
}
return $res;
}
$this->resultProfiles = array_merge($cards, $res);
$this->resultCount = count($this->resultProfiles);
return array_merge($cards, $res);
return $this;
}
@ -322,13 +328,21 @@ class RequestService
/**
* @param bool $value
* @return $this
* @return int
*/
public function count(bool $value = true): RequestService
public function count(bool $value = true): int
{
$this->returnCount = $value;
return $this;
return $this->resultCount;
}
/**
* @return array
*/
public function all(): array
{
return $this->resultProfiles;
}
public static function q()