diff --git a/src/Common.php b/src/Common.php index ed8ad41e..9d463bfa 100644 --- a/src/Common.php +++ b/src/Common.php @@ -102,4 +102,38 @@ public static function searchService(array $services, string $serviceName) : ?Se return $item; } + + + /** + * @param string $humanSize + * @return float|null + */ + public static function convertHumanSizeToBytes(string $humanSize) : ?float + { + $lastLetter = \substr($humanSize, -1); + if (\is_numeric($lastLetter)) { + return (float)$humanSize; + } + + $size = \substr($humanSize, 0, -1); + switch (\strtolower($lastLetter)) { + case 'b': + return (float)$size; + break; + + case 'k': + return (float)$size * 1024; + break; + + case 'm': + return (float)$size * 1024 * 1024; + break; + + case 'g': + return (float)$size * 1024 * 1024 * 1024; + break; + } + + return null; + } } diff --git a/src/Info.php b/src/Info.php index bb9a95e5..22a0427c 100644 --- a/src/Info.php +++ b/src/Info.php @@ -221,9 +221,11 @@ public function getPhp() : Php ->setZendExtensions(\get_loaded_extensions(true)) ->setIniFile(\php_ini_loaded_file()) ->setIncludePath(\get_include_path()) - ->setSapiName(\php_sapi_name()) + ->setSapiName(\PHP_SAPI) ->setDisabledFunctions($disabledFunctions ? \explode(',', $disabledFunctions) : []) ->setDisabledClasses($disabledClasses ? \explode(',', $disabledClasses) : []) + ->setRealpathCacheSizeUsed(\realpath_cache_size()) + ->setRealpathCacheSizeAllowed(Common::convertHumanSizeToBytes(\ini_get('realpath_cache_size'))) ->setOpcache( (new Php\Opcache()) ->setVersion(\phpversion('Zend Opcache') ?: null) diff --git a/src/Info/Php.php b/src/Info/Php.php index 91fd8039..72bda29a 100644 --- a/src/Info/Php.php +++ b/src/Info/Php.php @@ -27,6 +27,10 @@ class Php private $disabledFunctions; /** @var string[] */ private $disabledClasses; + /** @var float */ + private $realpathCacheSizeUsed; + /** @var float|null */ + private $realpathCacheSizeAllowed; /** * @return string @@ -207,4 +211,40 @@ public function setDisabledClasses(array $disabledClasses): self $this->disabledClasses = $disabledClasses; return $this; } + + /** + * @return float + */ + public function getRealpathCacheSizeUsed(): float + { + return $this->realpathCacheSizeUsed; + } + + /** + * @param float $realpathCacheSizeUsed + * @return $this + */ + public function setRealpathCacheSizeUsed(float $realpathCacheSizeUsed): self + { + $this->realpathCacheSizeUsed = $realpathCacheSizeUsed; + return $this; + } + + /** + * @return float|null + */ + public function getRealpathCacheSizeAllowed(): ?float + { + return $this->realpathCacheSizeAllowed; + } + + /** + * @param float|null $realpathCacheSizeAllowed + * @return $this + */ + public function setRealpathCacheSizeAllowed(?float $realpathCacheSizeAllowed): self + { + $this->realpathCacheSizeAllowed = $realpathCacheSizeAllowed; + return $this; + } }