Skip to content

Commit

Permalink
feat: added property filter to nuts (#5)
Browse files Browse the repository at this point in the history
Merging
  • Loading branch information
rasstislav authored Mar 11, 2024
1 parent 8841fb9 commit d556510
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public function getIsco(string $code)
* @param int|null $revisions
* @param int $page
* @param int $perPage
* @param array $properties
* @return mixed
* @throws \Psr\Cache\InvalidArgumentException
* @throws ReflectionException
Expand Down Expand Up @@ -913,14 +914,20 @@ public function getNuts(string $code)
* @param array $level
* @param int $page
* @param int $perPage
* @param array $properties
* @return mixed
* @throws \Psr\Cache\InvalidArgumentException
* @throws ReflectionException
*/
public function searchNuts(?string $title = null, array $level = [], $page = 1, $perPage = self::RESULTS_PER_PAGE)
public function searchNuts(?string $title = null, array $level = [], $page = 1, $perPage = self::RESULTS_PER_PAGE, array $properties = [])
{
$parameterNames = array_slice($this->methodParameterExtractor->extract(__CLASS__, __FUNCTION__), 0, func_num_args());
$args = array_combine($parameterNames, func_get_args());

if ($perPage === 0) {
$args['pagination'] = false;
}

$cacheKey = 'search-nuts-' . crc32(json_encode([$args]));
$result = $this->cache->get($cacheKey, function (ItemInterface $item) use ($args) {
$item->expiresAfter($this->cacheTtl);
Expand Down

0 comments on commit d556510

Please sign in to comment.