Skip to content

Commit

Permalink
add realpath_cache_size info
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemorroj committed Apr 13, 2018
1 parent 7a25aff commit 6d67337
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
4 changes: 3 additions & 1 deletion src/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
40 changes: 40 additions & 0 deletions src/Info/Php.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class Php
private $disabledFunctions;
/** @var string[] */
private $disabledClasses;
/** @var float */
private $realpathCacheSizeUsed;
/** @var float|null */
private $realpathCacheSizeAllowed;

/**
* @return string
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 6d67337

Please sign in to comment.