Skip to content

Commit

Permalink
chore: prefix all value accessors with value<type> (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
poppoerika authored Nov 14, 2022
1 parent fb60ba7 commit f61fc7b
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 92 deletions.
26 changes: 10 additions & 16 deletions src/Cache/CacheOperationTypes/CacheOperationTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Cache_client\_SetResponse;
use Cache_client\ECacheResult;
use Control_client\_ListCachesResponse;
use Momento\Cache\Errors\MomentoErrorCode;
use Momento\Cache\Errors\SdkError;
use Momento\Cache\Errors\UnknownError;

Expand Down Expand Up @@ -284,7 +283,7 @@ public function key(): string
return $this->key;
}

public function value(): string
public function valueString(): string
{
return $this->value;
}
Expand Down Expand Up @@ -338,7 +337,7 @@ public function __construct(_GetResponse $grpcGetResponse)
$this->value = $grpcGetResponse->getCacheBody();
}

public function value(): string
public function valueString(): string
{
return $this->value;
}
Expand Down Expand Up @@ -430,7 +429,7 @@ public function __construct(_ListFetchResponse $response)
}
}

public function values(): array
public function valuesArray(): array
{
return $this->values;
}
Expand Down Expand Up @@ -577,7 +576,7 @@ public function __construct(_ListPopFrontResponse $response)
$this->value = $response->getFound()->getFront();
}

public function value(): string
public function valueString(): string
{
return $this->value;
}
Expand Down Expand Up @@ -634,7 +633,7 @@ public function __construct(_ListPopBackResponse $response)
$this->value = $response->getFound()->getBack();
}

public function value(): string
public function valueString(): string
{
return $this->value;
}
Expand Down Expand Up @@ -825,7 +824,7 @@ public function __construct(_DictionaryGetResponse $response = null, ?string $ca
}
}

public function value(): string
public function valueString(): string
{
return $this->value;
}
Expand Down Expand Up @@ -1007,12 +1006,12 @@ public function __construct(_DictionaryGetResponse $responses = null, ?int $numR
}
}

public function values(): array
public function valuesArray(): array
{
$ret = [];
foreach ($this->responsesList as $response) {
if ($response->asHit()) {
$ret[] = $response->asHit()->value();
$ret[] = $response->asHit()->valueString();
}
if ($response->asMiss()) {
$ret[] = null;
Expand Down Expand Up @@ -1063,16 +1062,11 @@ public function __construct(_DictionaryIncrementResponse $response)
$this->value = $response->getValue();
}

public function value(): int
public function valueInt(): int
{
return $this->value;
}

public function string(): string
{
return "{$this->value}";
}

public function __toString()
{
return parent::__toString() . ": " . $this->value;
Expand Down Expand Up @@ -1208,7 +1202,7 @@ public function __construct(_SetFetchResponse $response)
}
}

public function stringSet(): array
public function valueArray(): array
{
return $this->stringSet;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/Psr16CacheClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function get(string $key, mixed $default = null): mixed
return $default;
}
$hit = $response->asHit();
return unserialize($hit->value());
return unserialize($hit->valueString());
}

/**
Expand Down
Loading

0 comments on commit f61fc7b

Please sign in to comment.