tonicforhealth / health-checker-check
health-checker的检查器的基本接口和抽象层
v0.2.1
2016-09-16 10:01 UTC
Requires
Requires (Dev)
- phpunit/phpunit: ^4.8|^5.3
This package is not auto-updated.
Last update: 2024-09-18 19:20:20 UTC
README
这是检查器的基本接口和抽象层。
使用Composer进行安装
$ composer require tonicforhealth/health-checker-check
需求
- PHP 5.5 或更高版本
用法
<?php use TonicHealthCheck\Check\AbstractCheck; class WeekendCheck extends AbstractCheck { const GROUP = 'date'; const COMPONENT = 'weekend'; const CHECK = 'weekend-date-check'; public function __construct($checkNode) { parent::__construct($checkNode); } /** * @throws giCheckException */ public function performCheck() { if ($this->isNotWeekend(date())) { throw new CheckException('Unfortunately weekend isn\'t today.'); } } protected function isNotWeekend($date) { return date('N', strtotime($date)) >= 6; } } $WeekendCheckI = new WeekendCheck('testnode'); $result = $WeekendCheckI->check(); if (!$result->isOk()) { echo $result->getError()->getMessage(); }