Skip to content

Commit

Permalink
add OpCacheCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
david-d-h committed Oct 16, 2023
1 parent acac0fd commit 431ec02
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Checks/OpCacheCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Vormkracht10\LaravelOK\Checks;

use Vormkracht10\LaravelOK\Checks\Base\Check;
use Vormkracht10\LaravelOK\Checks\Base\Result;

class OpCacheCheck extends Check
{
public function run(): Result
{
$result = Result::new();

if (! $this->opCacheIsRunning()) {
return $result->failed('OpCache is not running.');
}

return $result->ok('OpCache is running.');
}

protected function opCacheIsRunning(): bool
{
if (! function_exists('opcache_get_status')) {
return false;
}

$configuration = opcache_get_status();

return $configuration['opcache_enabled'] ?? false;
}
}

0 comments on commit 431ec02

Please sign in to comment.