From d5565106d99f7b91dd0a171641698443ca286ac7 Mon Sep 17 00:00:00 2001 From: Rastislav Brandobur Date: Mon, 11 Mar 2024 11:15:10 +0100 Subject: [PATCH] feat: added property filter to nuts (#5) Merging --- src/Client.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index 0f81496..2cfcd9c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -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 @@ -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);