Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Aug 20, 2019
1 parent e961637 commit a80be67
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/Manager.php
Expand Up @@ -42,21 +42,17 @@ public function __construct(int $capacity, float $rate, ?SerializerInterface $se

public function laodAllowance(string $name): array
{
try {
$value = $this->load($name);
if ($value === false) {
return [$this->capacity, 0];
}

$data = $this->serializer->unserialize($value);
if (!is_array($data) || count($data) !== 2) {
throw new \Exception('Invalid value');
}

return $data;
} catch (\Throwable $e) {
$value = $this->load($name);
if ($value === false) {
return [$this->capacity, 0];
}

$data = $this->serializer->unserialize($value);
if (!is_array($data) || count($data) !== 2) {
throw new \Exception('Invalid value');
}

return $data;
}

/**
Expand Down

0 comments on commit a80be67

Please sign in to comment.