open-orchestra/open-orchestra-base-bundle

View on GitHub
BaseBundle/HealthCheck/HealthCheckResult.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace OpenOrchestra\BaseBundle\HealthCheck;

/**
 * Class HealthCheckResult
 */
class HealthCheckResult
{
    protected $results = array();

    /**
     * @param HealthCheckTestResultInterface $result
     */
    public function addResult(HealthCheckTestResultInterface $result)
    {
        $this->results[] = $result;
    }

    /**
     * @param int $level
     *
     * @return bool
     */
    public function isSuccess($level = HealthCheckTestResultInterface::WARNING)
    {
        /** @var HealthCheckTestResultInterface $result */
        foreach ($this->results as $result) {
            if (true === $result->isError() && $result->getLevel() >= $level){
                return false;
            }
        }

        return true;
    }

    /**
     * @return array
     */
    public function getResults()
    {
        return $this->results;
    }
}