for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\ServerMonitor\CheckDefinitions;
use Exception;
use Spatie\ServerMonitor\Models\Check;
use Symfony\Component\Process\Process;
abstract class CheckDefinition
{
/** @var \Spatie\ServerMonitor\Models\Check */
protected $check;
/**
* @param \Spatie\ServerMonitor\Models\Check $check
*
* @return $this
*/
public function setCheck(Check $check)
$this->check = $check;
return $this;
}
public function getCommand(): string
return $this->command;
command
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
public function handleFinishedProcess(Process $process)
$this->check->storeProcessOutput($process);
try {
if (! $process->isSuccessful()) {
$this->handleFailedProcess($process);
return;
$this->handleSuccessfulProcess($process);
} catch (Exception $exception) {
$this->check->failed('Exception occurred: '.$exception->getMessage());
abstract public function handleSuccessfulProcess(Process $process);
public function handleFailedProcess(Process $process)
$this->check->failed("failed to run: {$process->getErrorOutput()}");
public function throttleFailingNotificationsForMinutes(): int
return config('server-monitor.notifications.throttle_failing_notifications_for_minutes');
abstract public function performNextRunInMinutes(): int;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: