Skip to content

Commit

Permalink
Get 100% code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSuisse committed Sep 13, 2019
1 parent f980734 commit 7ec8f14
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
10 changes: 1 addition & 9 deletions src/Storage/APCUStore.php
Expand Up @@ -11,7 +11,6 @@
use Enalean\Prometheus\Value\LabelNames;
use Enalean\Prometheus\Value\MetricLabelNames;
use Enalean\Prometheus\Value\MetricName;
use RuntimeException;
use const JSON_THROW_ON_ERROR;
use function apcu_add;
use function apcu_cas;
Expand Down Expand Up @@ -381,16 +380,9 @@ private function encodeLabelValues(array $values) : string

/**
* @return string[]
*
* @throws RuntimeException
*/
private function decodeLabelValues(string $values) : array
{
$json = base64_decode($values, true);
if ($json === false) {
throw new RuntimeException('Cannot base64 decode label values');
}

return json_decode($json, true, JSON_THROW_ON_ERROR);
return json_decode((string) base64_decode($values, true), true, JSON_THROW_ON_ERROR);
}
}
10 changes: 1 addition & 9 deletions src/Storage/InMemoryStore.php
Expand Up @@ -10,7 +10,6 @@
use Enalean\Prometheus\Value\LabelNames;
use Enalean\Prometheus\Value\MetricLabelNames;
use Enalean\Prometheus\Value\MetricName;
use RuntimeException;
use const JSON_THROW_ON_ERROR;
use function array_key_exists;
use function array_keys;
Expand Down Expand Up @@ -331,16 +330,9 @@ private function encodeLabelValues(array $values) : string

/**
* @return string[]
*
* @throws RuntimeException
*/
private function decodeLabelValues(string $values) : array
{
$json = base64_decode($values, true);
if ($json === false) {
throw new RuntimeException('Cannot base64 decode label values');
}

return json_decode($json, true, 512, JSON_THROW_ON_ERROR);
return json_decode((string) base64_decode($values, true), true, 512, JSON_THROW_ON_ERROR);
}
}

0 comments on commit 7ec8f14

Please sign in to comment.