Skip to content

Commit

Permalink
Merge pull request #41 from DarkGhostHunter/master
Browse files Browse the repository at this point in the history
Clearer exception.
  • Loading branch information
DarkGhostHunter committed Jul 5, 2020
2 parents c6cddeb + 0ac149e commit 9cfd645
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This package generates a [PHP 7.4 preloading](https://www.php.net/manual/en/opca
- [Configuration](#configuration)
* [Conditions](#conditions)
+ [`when()`](#when)
+ [`whenOneIn()`](#whenOneIn)
* [Listing](#listing)
+ [`append()`](#append)
+ [`exclude()`](#exclude)
Expand Down
19 changes: 13 additions & 6 deletions src/Opcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,38 @@

namespace DarkGhostHunter\Preloader;

use RuntimeException;

/**
* Class Opcache
*
* This is just a class to enable mocking for testing
*
* @package DarkGhostHunter\Preloader
*/
class Opcache
{
/**
* Her we will save the Opcache status instead of retrieving it every time from Opcache
* Here we will save the Opcache status instead of retrieving it every time.
*
* @var array
* @var array|false
*/
protected array $status;
protected $status;

/**
* Get status information about the cache
*
* @see https://www.php.net/manual/en/function.opcache-get-status.php
* @return array
* @throws \RuntimeException When Opcache is disabled.
*/
public function getStatus() : array
{
return $this->status ??= opcache_get_status(true);
if ($this->status ??= opcache_get_status(true)) {
return $this->status;
}

throw new RuntimeException(
'Opcache is disabled. Further reference: https://www.php.net/manual/en/opcache.configuration'
);
}

/**
Expand Down

0 comments on commit 9cfd645

Please sign in to comment.