for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace hamburgscleanest\GuzzleAdvancedThrottle\Cache\Adapters;
use DateTime;
use hamburgscleanest\GuzzleAdvancedThrottle\Cache\Interfaces\StorageInterface;
use hamburgscleanest\GuzzleAdvancedThrottle\RequestInfo;
/**
* Class ArrayAdapter
* @package hamburgscleanest\GuzzleAdvancedThrottle\Cache\Adapters
*/
class ArrayAdapter implements StorageInterface
{
/** @var array */
private $_storage = [];
* @param string $host
* @param string $key
* @param int $requestCount
* @param \DateTime $expiresAt
* @param int $remainingSeconds
public function save(string $host, string $key, int $requestCount, DateTime $expiresAt, int $remainingSeconds) : void
if (!isset($this->_storage[$host]))
$this->_storage[$host] = [];
}
$this->_storage[$host][$key] = RequestInfo::create($requestCount, $expiresAt->getTimestamp(), $remainingSeconds);
* @return RequestInfo|null
public function get(string $host, string $key) : ? RequestInfo
return $this->_storage[$host][$key] ?? null;