PHP code example of tonicforhealth / health-checker-check

1. Go to this page and download the library: Download tonicforhealth/health-checker-check library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tonicforhealth / health-checker-check example snippets




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();
}