public function getStatus($serviceName = null)
    {
        $this->setNamespace($serviceName);

        $success = false;
        $failures = (int) $this->storage->getItem('failures', $success);
        if (!$success) {
            $failures = 0;
            $this->storage->setItem('failures', $failures);
        }

        // Still has failures left
        if ($failures < $this->maxFailures) {
            return CerberusInterface::CLOSED;
        }

        $success = false;
        $lastAttempt = $this->storage->getItem('last_attempt', $success);

        // This is the first attempt after a failure, open the circuit
        if (!$success) {
            $lastAttempt = time();
            $this->storage->setItem('last_attempt', $lastAttempt);

            return CerberusInterface::OPEN;
        }

        // Reached maxFailues but has passed the timeout limit, so we can try again
        // We update the lastAttempt so only one call passes through
        if (time() - $lastAttempt >= $this->timeout) {
            $lastAttempt = time();
            $this->storage->setItem('last_attempt', $lastAttempt);

            return CerberusInterface::HALF_OPEN;
        }

        return CerberusInterface::OPEN;
    }
public function getStatus($serviceName = null)
    {
        $this->setNamespace($serviceName);

        $success = false;
        $failures = (int) $this->storage->getItem('failures', $success);
        if (!$success) {
            $failures = 0;
            $this->storage->setItem('failures', $failures);
        }

        // Still has failures left
        if ($failures < $this->maxFailures) {
            return CerberusInterface::CLOSED;
        }

        $success = false;
        $lastAttempt = $this->storage->getItem('last_attempt', $success);

        // This is the first attempt after a failure, open the circuit
        if (!$success) {
            $lastAttempt = time();
            $this->storage->setItem('last_attempt', $lastAttempt);

            return CerberusInterface::OPEN;
        }

        // Reached maxFailues but has passed the timeout limit, so we can try again
        // We update the lastAttempt so only one call passes through
        if (time() - $lastAttempt >= $this->timeout) {
            $lastAttempt = time();
            $this->storage->setItem('last_attempt', $lastAttempt);

            return CerberusInterface::HALF_OPEN;
        }

        return CerberusInterface::OPEN;
    }
{@inheritdoc}

@see \Cerberus\CerberusInterface::getStatus()