From 7efdf3ddf77e5dc8b4c70538d2a4b2de55103ea6 Mon Sep 17 00:00:00 2001 From: pgautier404 Date: Mon, 27 Mar 2023 17:34:56 -0700 Subject: [PATCH] fix: rename items to elements (#120) --- src/Cache/CacheClient.php | 6 +++--- src/Cache/Internal/ScsDataClient.php | 9 ++++----- src/Utilities/_DataValidation.php | 7 ------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/Cache/CacheClient.php b/src/Cache/CacheClient.php index 88d67617..49a52036 100644 --- a/src/Cache/CacheClient.php +++ b/src/Cache/CacheClient.php @@ -503,7 +503,7 @@ public function dictionaryFetch(string $cacheName, string $dictionaryName): Dict * * @param string $cacheName Name of the cache that contains the dictionary. * @param string $dictionaryName The dictionary to set the field in. Will be created if it doesn't exist. - * @param array $items The field-value pairs o be stored. + * @param array $elements The field-value pairs to be stored. * @param CollectionTtl|null $ttl TTL for the dictionary in cache. This TTL takes precedence over the TTL used when initializing a cache client. Defaults to client TTL. * @return DictionarySetFieldsResponse Represents the result of the dictionary set field operation. * This result is resolved to a type-safe object of one of the following types:
@@ -514,9 +514,9 @@ public function dictionaryFetch(string $cacheName, string $dictionaryName): Dict *   // handle error condition
* } */ - public function dictionarySetFields(string $cacheName, string $dictionaryName, array $items, ?CollectionTtl $ttl = null): DictionarySetFieldsResponse + public function dictionarySetFields(string $cacheName, string $dictionaryName, array $elements, ?CollectionTtl $ttl = null): DictionarySetFieldsResponse { - return $this->dataClient->dictionarySetFields($cacheName, $dictionaryName, $items, $ttl); + return $this->dataClient->dictionarySetFields($cacheName, $dictionaryName, $elements, $ttl); } /** diff --git a/src/Cache/Internal/ScsDataClient.php b/src/Cache/Internal/ScsDataClient.php index 0ecb8f9b..163f7d09 100644 --- a/src/Cache/Internal/ScsDataClient.php +++ b/src/Cache/Internal/ScsDataClient.php @@ -124,7 +124,6 @@ use function Momento\Utilities\validateElement; use function Momento\Utilities\validateFieldName; use function Momento\Utilities\validateFields; -use function Momento\Utilities\validateItems; use function Momento\Utilities\validateKeys; use function Momento\Utilities\validateListName; use function Momento\Utilities\validateNullOrEmpty; @@ -560,16 +559,16 @@ public function dictionaryFetch(string $cacheName, string $dictionaryName): Dict return new DictionaryFetchMiss(); } - public function dictionarySetFields(string $cacheName, string $dictionaryName, array $items, ?CollectionTtl $ttl = null): DictionarySetFieldsResponse + public function dictionarySetFields(string $cacheName, string $dictionaryName, array $elements, ?CollectionTtl $ttl = null): DictionarySetFieldsResponse { try { $collectionTtl = $this->returnCollectionTtl($ttl); validateCacheName($cacheName); validateDictionaryName($dictionaryName); - validateKeys(array_keys($items)); + validateKeys(array_keys($elements)); $ttlMillis = $this->ttlToMillis($collectionTtl->getTtl()); $protoItems = []; - foreach ($items as $field => $value) { + foreach ($elements as $field => $value) { $fieldValuePair = new _DictionaryFieldValuePair(); $fieldValuePair->setField($field); $fieldValuePair->setValue($value); @@ -595,7 +594,7 @@ public function dictionaryGetFields(string $cacheName, string $dictionaryName, a try { validateCacheName($cacheName); validateDictionaryName($dictionaryName); - validateItems($fields); + validateFields($fields); $dictionaryGetFieldsRequest = new _DictionaryGetRequest(); $dictionaryGetFieldsRequest->setDictionaryName($dictionaryName); $dictionaryGetFieldsRequest->setFields($fields); diff --git a/src/Utilities/_DataValidation.php b/src/Utilities/_DataValidation.php index b65537dd..40e002d8 100644 --- a/src/Utilities/_DataValidation.php +++ b/src/Utilities/_DataValidation.php @@ -103,13 +103,6 @@ function validateValueName(string $valueName): void } } -if (!function_exists('validateItems')) { - function validateItems(array $items): void - { - validateNullOrEmptyList($items, "Items"); - } -} - if (!function_exists('validateOperationTimeout')) { function validateOperationTimeout(?int $operationTimeout = null) {