for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Leankoala\HealthFoundation\Filter\Time;
use Leankoala\HealthFoundation\Check\MetricAwareResult;
use Leankoala\HealthFoundation\Check\Result;
use Leankoala\HealthFoundation\Filter\BasicFilter;
class DailyFilter extends BasicFilter
{
private $hour;
private $reason = false;
public function init($hour, $reason = false)
$this->hour = $hour;
$this->reason = $reason;
}
public function run()
$result = $this->getCheck()->run();
$currentHour = (int)date('H');
if ($result->getStatus() == Result::STATUS_FAIL) {
if ($currentHour == $this->hour) {
if ($this->reason) {
$message = $this->reason . ' (fail reason was: ' . $result->getMessage() . ')';
$this->reason
true
concatenation
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
$message = /** @scrutinizer ignore-type */ $this->reason . ' (fail reason was: ' . $result->getMessage() . ')';
} else {
$message = 'Passed due daily filter (fail reason was: ' . $result->getMessage() . ')';
if ($result instanceof MetricAwareResult) {
$newResult = new MetricAwareResult(Result::STATUS_PASS, $message);
$newResult->setMetric($result->getMetricValue(), $result->getMetricUnit());
$newResult = new Result(Result::STATUS_PASS, $message);
return $newResult;
return $result;