mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
Use global namespace
This commit is contained in:
parent
665a9d4655
commit
4cdfab275e
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace phpOMS;
|
namespace phpOMS;
|
||||||
|
|
||||||
spl_autoload_register('\phpOMS\Autoloader::defaultAutoloader');
|
\spl_autoload_register('\phpOMS\Autoloader::defaultAutoloader');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Autoloader class.
|
* Autoloader class.
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ final class FinanceFormulas
|
||||||
*/
|
*/
|
||||||
public static function getNumberOfAPPV(float $p, float $pv, float $r) : int
|
public static function getNumberOfAPPV(float $p, float $pv, float $r) : int
|
||||||
{
|
{
|
||||||
return (int) \round(-log(-($r * $pv / $p - 1)) / \log(1 + $r));
|
return (int) \round(-\log(-($r * $pv / $p - 1)) / \log(1 + $r));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -286,7 +286,7 @@ final class FinanceFormulas
|
||||||
*/
|
*/
|
||||||
public static function getNumberOfAPFPV(float $p, float $r) : int
|
public static function getNumberOfAPFPV(float $p, float $r) : int
|
||||||
{
|
{
|
||||||
return (int) \round(-log(-($r / $p - 1)) / \log(1 + $r));
|
return (int) \round(-\log(-($r / $p - 1)) / \log(1 + $r));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -318,7 +318,7 @@ final class FinanceFormulas
|
||||||
*/
|
*/
|
||||||
public static function getNumberOfPeriodsOfPVA(float $pva, float $P, float $r) : int
|
public static function getNumberOfPeriodsOfPVA(float $pva, float $P, float $r) : int
|
||||||
{
|
{
|
||||||
return (int) \round(-log(-($pva / $P * $r - 1)) / \log(1 + $r));
|
return (int) \round(-\log(-($pva / $P * $r - 1)) / \log(1 + $r));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -364,7 +364,7 @@ final class FinanceFormulas
|
||||||
*/
|
*/
|
||||||
public static function getPeriodsOfPVAF(float $p, float $r) : int
|
public static function getPeriodsOfPVAF(float $p, float $r) : int
|
||||||
{
|
{
|
||||||
return (int) \round(-log(-($p * $r - 1)) / \log(1 + $r));
|
return (int) \round(-\log(-($p * $r - 1)) / \log(1 + $r));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -813,7 +813,7 @@ final class FinanceFormulas
|
||||||
*/
|
*/
|
||||||
public static function getPeriodsOfEAA(float $C, float $NPV, float $r) : int
|
public static function getPeriodsOfEAA(float $C, float $NPV, float $r) : int
|
||||||
{
|
{
|
||||||
return (int) \round(-log(1 - $r * $NPV / $C) / \log(1 + $r));
|
return (int) \round(-\log(1 - $r * $NPV / $C) / \log(1 + $r));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ final class CookieJar
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\headers_sent()) {
|
if (!\headers_sent()) {
|
||||||
\setcookie($id, '', time() - 3600);
|
\setcookie($id, '', \time() - 3600);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
self::$collection['ownsOne'][] = $class::$ownsOne;
|
self::$collection['ownsOne'][] = $class::$ownsOne;
|
||||||
self::$collection['table'][] = $class::$table;
|
self::$collection['table'][] = $class::$table;
|
||||||
|
|
||||||
if (($parent = get_parent_class($class)) !== false && !$class::$overwrite) {
|
if (($parent = \get_parent_class($class)) !== false && !$class::$overwrite) {
|
||||||
self::extend($parent);
|
self::extend($parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ final class Money implements \Serializable
|
||||||
throw new \Exception();
|
throw new \Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($decimals > 0) ? number_format((float) $left, 0, $this->decimal, $this->thousands) . $this->decimal . \substr($right, 0, $decimals) : $left;
|
return ($decimals > 0) ? \number_format((float) $left, 0, $this->decimal, $this->thousands) . $this->decimal . \substr($right, 0, $decimals) : $left;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -502,7 +502,7 @@ final class FileLogger implements LoggerInterface
|
||||||
|
|
||||||
if ($limit <= 0) {
|
if ($limit <= 0) {
|
||||||
\reset($logs);
|
\reset($logs);
|
||||||
unset($logs[key($logs)]);
|
unset($logs[\key($logs)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($line as &$value) {
|
foreach ($line as &$value) {
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ final class Functions
|
||||||
$min = \min([$k, $n - $k]);
|
$min = \min([$k, $n - $k]);
|
||||||
|
|
||||||
$fact = 1;
|
$fact = 1;
|
||||||
$range = array_reverse(\range(1, $min));
|
$range = \array_reverse(\range(1, $min));
|
||||||
|
|
||||||
for ($i = $max + 1; $i < $n + 1; ++$i) {
|
for ($i = $max + 1; $i < $n + 1; ++$i) {
|
||||||
$div = 1;
|
$div = 1;
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ final class Gamma
|
||||||
public static function spougeApproximation($z) : float
|
public static function spougeApproximation($z) : float
|
||||||
{
|
{
|
||||||
$k1_fact = 1.0;
|
$k1_fact = 1.0;
|
||||||
$c = [sqrt(2.0 * M_PI)];
|
$c = [\sqrt(2.0 * M_PI)];
|
||||||
|
|
||||||
for ($k = 1; $k < 12; ++$k) {
|
for ($k = 1; $k < 12; ++$k) {
|
||||||
$c[$k] = \exp(12 - $k) * \pow(12 - $k, $k - 0.5) / $k1_fact;
|
$c[$k] = \exp(12 - $k) * \pow(12 - $k, $k - 0.5) / $k1_fact;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ final class Circle implements D2ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getSurface(float $r) : float
|
public static function getSurface(float $r) : float
|
||||||
{
|
{
|
||||||
return pi() * $r ** 2;
|
return \pi() * $r ** 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,7 +50,7 @@ final class Circle implements D2ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getPerimeter(float $r) : float
|
public static function getPerimeter(float $r) : float
|
||||||
{
|
{
|
||||||
return 2 * pi() * $r;
|
return 2 * \pi() * $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,7 +64,7 @@ final class Circle implements D2ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getRadiusBySurface(float $surface) : float
|
public static function getRadiusBySurface(float $surface) : float
|
||||||
{
|
{
|
||||||
return \sqrt($surface / pi());
|
return \sqrt($surface / \pi());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -81,6 +81,6 @@ final class Circle implements D2ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getRadiusByPerimeter(float $C) : float
|
public static function getRadiusByPerimeter(float $C) : float
|
||||||
{
|
{
|
||||||
return $C / (2 * pi());
|
return $C / (2 * \pi());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ final class Ellipse implements D2ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getSurface(float $a, float $b) : float
|
public static function getSurface(float $a, float $b) : float
|
||||||
{
|
{
|
||||||
return pi() * $a * $b;
|
return \pi() * $a * $b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,6 +62,6 @@ final class Ellipse implements D2ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getPerimeter(float $a, float $b) : float
|
public static function getPerimeter(float $a, float $b) : float
|
||||||
{
|
{
|
||||||
return pi() * ($a + $b) * (3 * ($a - $b) ** 2 / (($a + $b) ** 2 * (\sqrt(-3 * ($a - $b) ** 2 / (($a + $b) ** 2) + 4) + 10)) + 1);
|
return \pi() * ($a + $b) * (3 * ($a - $b) ** 2 / (($a + $b) ** 2 * (\sqrt(-3 * ($a - $b) ** 2 / (($a + $b) ** 2) + 4) + 10)) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ final class Cone implements D3ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getVolume(float $r, float $h) : float
|
public static function getVolume(float $r, float $h) : float
|
||||||
{
|
{
|
||||||
return pi() * $r ** 2 * $h / 3;
|
return \pi() * $r ** 2 * $h / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -52,7 +52,7 @@ final class Cone implements D3ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getSurface(float $r, float $h) : float
|
public static function getSurface(float $r, float $h) : float
|
||||||
{
|
{
|
||||||
return pi() * $r * ($r + \sqrt($h ** 2 + $r ** 2));
|
return \pi() * $r * ($r + \sqrt($h ** 2 + $r ** 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -85,6 +85,6 @@ final class Cone implements D3ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getHeightFromVolume(float $V, float $r) : float
|
public static function getHeightFromVolume(float $V, float $r) : float
|
||||||
{
|
{
|
||||||
return 3 * $V / (pi() * $r ** 2);
|
return 3 * $V / (\pi() * $r ** 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ final class Cylinder implements D3ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getVolume(float $r, float $h) : float
|
public static function getVolume(float $r, float $h) : float
|
||||||
{
|
{
|
||||||
return pi() * $r ** 2 * $h;
|
return \pi() * $r ** 2 * $h;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -52,7 +52,7 @@ final class Cylinder implements D3ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getSurface(float $r, float $h) : float
|
public static function getSurface(float $r, float $h) : float
|
||||||
{
|
{
|
||||||
return 2 * pi() * ($r * $h + $r ** 2);
|
return 2 * \pi() * ($r * $h + $r ** 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -67,6 +67,6 @@ final class Cylinder implements D3ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getLateralSurface(float $r, float $h) : float
|
public static function getLateralSurface(float $r, float $h) : float
|
||||||
{
|
{
|
||||||
return 2 * pi() * $r * $h;
|
return 2 * \pi() * $r * $h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,10 @@ final class Sphere implements D3ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function distance2PointsOnSphere(float $latStart, float $longStart, float $latEnd, float $longEnd, float $radius = 6371000.0) : float
|
public static function distance2PointsOnSphere(float $latStart, float $longStart, float $latEnd, float $longEnd, float $radius = 6371000.0) : float
|
||||||
{
|
{
|
||||||
$latFrom = deg2rad($latStart);
|
$latFrom = \deg2rad($latStart);
|
||||||
$lonFrom = deg2rad($longStart);
|
$lonFrom = \deg2rad($longStart);
|
||||||
$latTo = deg2rad($latEnd);
|
$latTo = \deg2rad($latEnd);
|
||||||
$lonTo = deg2rad($longEnd);
|
$lonTo = \deg2rad($longEnd);
|
||||||
|
|
||||||
//$latDelta = $latTo - $latFrom;
|
//$latDelta = $latTo - $latFrom;
|
||||||
$lonDelta = $lonTo - $lonFrom;
|
$lonDelta = $lonTo - $lonFrom;
|
||||||
|
|
@ -70,7 +70,7 @@ final class Sphere implements D3ShapeInterface
|
||||||
$a = \pow(\cos($latTo) * \sin($lonDelta), 2) + \pow(\cos($latFrom) * \sin($latTo) - \sin($latFrom) * \cos($latTo) * \cos($lonDelta), 2);
|
$a = \pow(\cos($latTo) * \sin($lonDelta), 2) + \pow(\cos($latFrom) * \sin($latTo) - \sin($latFrom) * \cos($latTo) * \cos($lonDelta), 2);
|
||||||
$b = \sin($latFrom) * \sin($latTo) + \cos($latFrom) * \cos($latTo) * \cos($lonDelta);
|
$b = \sin($latFrom) * \sin($latTo) + \cos($latFrom) * \cos($latTo) * \cos($lonDelta);
|
||||||
|
|
||||||
$angle = atan2(\sqrt($a), $b);
|
$angle = \atan2(\sqrt($a), $b);
|
||||||
// Approximation (very good for short distances)
|
// Approximation (very good for short distances)
|
||||||
// $angle = 2 * asin(\sqrt(\pow(\sin($latDelta / 2), 2) + \cos($latFrom) * \cos($latTo) * \pow(\sin($lonDelta / 2), 2)));
|
// $angle = 2 * asin(\sqrt(\pow(\sin($latDelta / 2), 2) + \cos($latFrom) * \cos($latTo) * \pow(\sin($lonDelta / 2), 2)));
|
||||||
|
|
||||||
|
|
@ -116,7 +116,7 @@ final class Sphere implements D3ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getRadiusByVolume(float $v) : float
|
public static function getRadiusByVolume(float $v) : float
|
||||||
{
|
{
|
||||||
return \pow($v * 3 / (4 * pi()), 1 / 3);
|
return \pow($v * 3 / (4 * \pi()), 1 / 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -147,7 +147,7 @@ final class Sphere implements D3ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getRadiusBySurface(float $S) : float
|
public static function getRadiusBySurface(float $S) : float
|
||||||
{
|
{
|
||||||
return \sqrt($S / (4 * pi()));
|
return \sqrt($S / (4 * \pi()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -173,7 +173,7 @@ final class Sphere implements D3ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getVolumeByRadius(float $r) : float
|
public static function getVolumeByRadius(float $r) : float
|
||||||
{
|
{
|
||||||
return 4 / 3 * pi() * $r ** 3;
|
return 4 / 3 * \pi() * $r ** 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -211,6 +211,6 @@ final class Sphere implements D3ShapeInterface
|
||||||
*/
|
*/
|
||||||
public static function getSurfaceByRadius(float $r) : float
|
public static function getSurfaceByRadius(float $r) : float
|
||||||
{
|
{
|
||||||
return 4 * pi() * $r ** 2;
|
return 4 * \pi() * $r ** 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -402,7 +402,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
{
|
{
|
||||||
if ($value instanceof self) {
|
if ($value instanceof self) {
|
||||||
return $this->add($value->mult(-1));
|
return $this->add($value->mult(-1));
|
||||||
} elseif (!\is_string($value) && is_numeric($value)) {
|
} elseif (!\is_string($value) && \is_numeric($value)) {
|
||||||
return $this->add(-$value);
|
return $this->add(-$value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -424,7 +424,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
{
|
{
|
||||||
if ($value instanceof self) {
|
if ($value instanceof self) {
|
||||||
return $this->addMatrix($value);
|
return $this->addMatrix($value);
|
||||||
} elseif (!\is_string($value) && is_numeric($value)) {
|
} elseif (!\is_string($value) && \is_numeric($value)) {
|
||||||
return $this->addScalar($value);
|
return $this->addScalar($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -529,7 +529,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
{
|
{
|
||||||
if ($value instanceof self) {
|
if ($value instanceof self) {
|
||||||
return $this->multMatrix($value);
|
return $this->multMatrix($value);
|
||||||
} elseif (!\is_string($value) && is_numeric($value)) {
|
} elseif (!\is_string($value) && \is_numeric($value)) {
|
||||||
return $this->multScalar($value);
|
return $this->multScalar($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -359,7 +359,7 @@ final class SingularValueDecomposition
|
||||||
$shift = 0.0;
|
$shift = 0.0;
|
||||||
|
|
||||||
if ($b != 0 || $c != 0) {
|
if ($b != 0 || $c != 0) {
|
||||||
$shift = sqrt($b * $b + $c);
|
$shift = \sqrt($b * $b + $c);
|
||||||
if ($b < 0.0) {
|
if ($b < 0.0) {
|
||||||
$shift = -$shift;
|
$shift = -$shift;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -406,11 +406,11 @@ final class Complex
|
||||||
*/
|
*/
|
||||||
public function render(int $precision = 2) : string
|
public function render(int $precision = 2) : string
|
||||||
{
|
{
|
||||||
return ($this->re !== 0 ? number_format($this->re, $precision) : '')
|
return ($this->re !== 0 ? \number_format($this->re, $precision) : '')
|
||||||
. ($this->im > 0 && $this->re !== 0 ? ' +' : '')
|
. ($this->im > 0 && $this->re !== 0 ? ' +' : '')
|
||||||
. ($this->im < 0 && $this->re !== 0 ? ' -' : '')
|
. ($this->im < 0 && $this->re !== 0 ? ' -' : '')
|
||||||
. ($this->im !== 0 ? (
|
. ($this->im !== 0 ? (
|
||||||
($this->re !== 0 ? ' ' : '') . number_format(
|
($this->re !== 0 ? ' ' : '') . \number_format(
|
||||||
($this->im < 0 && $this->re === 0 ? $this->im : \abs($this->im)), $precision
|
($this->im < 0 && $this->re === 0 ? $this->im : \abs($this->im)), $precision
|
||||||
) . 'i'
|
) . 'i'
|
||||||
) : '');
|
) : '');
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ final class Integer
|
||||||
*/
|
*/
|
||||||
public static function isInteger($value) : bool
|
public static function isInteger($value) : bool
|
||||||
{
|
{
|
||||||
return is_int($value);
|
return \is_int($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -159,7 +159,7 @@ final class Integer
|
||||||
throw new \Exception('Only odd integers are allowed');
|
throw new \Exception('Only odd integers are allowed');
|
||||||
}
|
}
|
||||||
|
|
||||||
$a = (int) ceil(\sqrt($value));
|
$a = (int) \ceil(\sqrt($value));
|
||||||
$b2 = ($a * $a - $value);
|
$b2 = ($a * $a - $value);
|
||||||
$i = 1;
|
$i = 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,6 @@ final class Natural
|
||||||
*/
|
*/
|
||||||
public static function isNatural($value) : bool
|
public static function isNatural($value) : bool
|
||||||
{
|
{
|
||||||
return is_int($value) && $value >= 0;
|
return \is_int($value) && $value >= 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ final class Prime
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < $k; ++$i) {
|
for ($i = 0; $i < $k; ++$i) {
|
||||||
$a = mt_rand(2, $n - 1);
|
$a = \mt_rand(2, $n - 1);
|
||||||
|
|
||||||
$x = \bcpowmod((string) $a, (string) $d, (string) $n);
|
$x = \bcpowmod((string) $a, (string) $d, (string) $n);
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ final class Prime
|
||||||
{
|
{
|
||||||
$number = 2;
|
$number = 2;
|
||||||
$range = \range(2, $n);
|
$range = \range(2, $n);
|
||||||
$primes = array_combine($range, $range);
|
$primes = \array_combine($range, $range);
|
||||||
|
|
||||||
while ($number * $number < $n) {
|
while ($number * $number < $n) {
|
||||||
for ($i = $number; $i <= $n; $i += $number) {
|
for ($i = $number; $i <= $n; $i += $number) {
|
||||||
|
|
@ -147,7 +147,7 @@ final class Prime
|
||||||
$number = \next($primes);
|
$number = \next($primes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_values($primes);
|
return \array_values($primes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class BinomialDistribution
|
||||||
*/
|
*/
|
||||||
public static function getMode(int $n, float $p) : float
|
public static function getMode(int $n, float $p) : float
|
||||||
{
|
{
|
||||||
return floor(($n + 1) * $p);
|
return \floor(($n + 1) * $p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -157,7 +157,7 @@ class BinomialDistribution
|
||||||
*/
|
*/
|
||||||
public static function getMedian(int $n, float $p) : float
|
public static function getMedian(int $n, float $p) : float
|
||||||
{
|
{
|
||||||
return floor($n * $p);
|
return \floor($n * $p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class CauchyDistribution
|
||||||
*/
|
*/
|
||||||
public static function getPdf(float $x, float $x0, float $gamma) : float
|
public static function getPdf(float $x, float $x0, float $gamma) : float
|
||||||
{
|
{
|
||||||
return 1 / (pi() * $gamma * (1 + (($x - $x0) / $gamma) ** 2));
|
return 1 / (\pi() * $gamma * (1 + (($x - $x0) / $gamma) ** 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -53,7 +53,7 @@ class CauchyDistribution
|
||||||
*/
|
*/
|
||||||
public static function getCdf(float $x, float $x0, float $gamma) : float
|
public static function getCdf(float $x, float $x0, float $gamma) : float
|
||||||
{
|
{
|
||||||
return 1 / pi() * atan(($x - $x0) / $gamma) + 0.5;
|
return 1 / \pi() * \atan(($x - $x0) / $gamma) + 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ class ChiSquaredDistribution
|
||||||
$df = self::getDegreesOfFreedom($dataset);
|
$df = self::getDegreesOfFreedom($dataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('self::TABLE') || !\array_key_exists($df, self::TABLE)) {
|
if (!\defined('self::TABLE') || !\array_key_exists($df, self::TABLE)) {
|
||||||
throw new \Exception('Degrees of freedom not supported');
|
throw new \Exception('Degrees of freedom not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ class GeometricDistribution
|
||||||
*/
|
*/
|
||||||
public static function getMedian(float $p) : float
|
public static function getMedian(float $p) : float
|
||||||
{
|
{
|
||||||
return ceil(-1 / (\log(1 - $p, 2)));
|
return \ceil(-1 / (\log(1 - $p, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class LaplaceDistribution
|
||||||
*/
|
*/
|
||||||
public static function getPdf(float $x, float $mu, float $b) : float
|
public static function getPdf(float $x, float $mu, float $b) : float
|
||||||
{
|
{
|
||||||
return 1 / (2 * $b) * \exp(-abs($x - $mu) / $b);
|
return 1 / (2 * $b) * \exp(-\abs($x - $mu) / $b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class NormalDistribution
|
||||||
*/
|
*/
|
||||||
public static function getPdf(float $x, float $mu, float $sig) : float
|
public static function getPdf(float $x, float $mu, float $sig) : float
|
||||||
{
|
{
|
||||||
return 1 / ($sig * \sqrt(2 * pi())) * \exp(-($x - $mu) ** 2 / (2 * $sig ** 2));
|
return 1 / ($sig * \sqrt(2 * \pi())) * \exp(-($x - $mu) ** 2 / (2 * $sig ** 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,9 +72,9 @@ class NormalDistribution
|
||||||
return -self::erf(-$x);
|
return -self::erf(-$x);
|
||||||
}
|
}
|
||||||
|
|
||||||
$a = 8 * (pi() - 3) / (3 * pi() * (4 - pi()));
|
$a = 8 * (\pi() - 3) / (3 * \pi() * (4 - \pi()));
|
||||||
|
|
||||||
return \sqrt(1 - \exp(-($x ** 2) * (4 / pi() + $a * $x ** 2) / (1 + $a * $x ** 2)));
|
return \sqrt(1 - \exp(-($x ** 2) * (4 / \pi() + $a * $x ** 2) / (1 + $a * $x ** 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ final class Header extends HeaderAbstract
|
||||||
*/
|
*/
|
||||||
public function get(string $key) : array
|
public function get(string $key) : array
|
||||||
{
|
{
|
||||||
return $this->header[strtolower($key)] ?? [];
|
return $this->header[\strtolower($key)] ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ final class Request extends RequestAbstract
|
||||||
$paths[] = $pathArray[$i];
|
$paths[] = $pathArray[$i];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->hash[] = sha1(\implode('', $paths));
|
$this->hash[] = \sha1(\implode('', $paths));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ abstract class InstallerAbstract
|
||||||
foreach ($load as $val) {
|
foreach ($load as $val) {
|
||||||
foreach ($val['pid'] as $pid) {
|
foreach ($val['pid'] as $pid) {
|
||||||
$queryLoad->values(
|
$queryLoad->values(
|
||||||
sha1(\str_replace('/', '', $pid)),
|
\sha1(\str_replace('/', '', $pid)),
|
||||||
(int) $val['type'],
|
(int) $val['type'],
|
||||||
$val['from'],
|
$val['from'],
|
||||||
$val['for'],
|
$val['for'],
|
||||||
|
|
|
||||||
|
|
@ -69,14 +69,14 @@ class Client extends SocketAbstract
|
||||||
*/
|
*/
|
||||||
public function run() : void
|
public function run() : void
|
||||||
{
|
{
|
||||||
socket_connect($this->sock, $this->ip, $this->port);
|
\socket_connect($this->sock, $this->ip, $this->port);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while ($this->run) {
|
while ($this->run) {
|
||||||
try {
|
try {
|
||||||
$i++;
|
$i++;
|
||||||
$msg = 'disconnect';
|
$msg = 'disconnect';
|
||||||
socket_write($this->sock, $msg, \strlen($msg));
|
\socket_write($this->sock, $msg, \strlen($msg));
|
||||||
|
|
||||||
$read = [$this->sock];
|
$read = [$this->sock];
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ class Client extends SocketAbstract
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (\count($read) > 0) {
|
if (\count($read) > 0) {
|
||||||
$data = socket_read($this->sock, 1024);
|
$data = \socket_read($this->sock, 1024);
|
||||||
|
|
||||||
/* Server no data */
|
/* Server no data */
|
||||||
if ($data === false) {
|
if ($data === false) {
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ class Server extends SocketAbstract
|
||||||
*/
|
*/
|
||||||
public static function hasInternet() : bool
|
public static function hasInternet() : bool
|
||||||
{
|
{
|
||||||
$connected = @fsockopen("www.google.com", 80);
|
$connected = @\fsockopen("www.google.com", 80);
|
||||||
|
|
||||||
if ($connected) {
|
if ($connected) {
|
||||||
\fclose($connected);
|
\fclose($connected);
|
||||||
|
|
@ -108,7 +108,7 @@ class Server extends SocketAbstract
|
||||||
$this->app->logger->info('Creating socket...');
|
$this->app->logger->info('Creating socket...');
|
||||||
parent::create($ip, $port);
|
parent::create($ip, $port);
|
||||||
$this->app->logger->info('Binding socket...');
|
$this->app->logger->info('Binding socket...');
|
||||||
socket_bind($this->sock, $this->ip, $this->port);
|
\socket_bind($this->sock, $this->ip, $this->port);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -155,13 +155,13 @@ class Server extends SocketAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
$acceptKey = $key . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
|
$acceptKey = $key . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
|
||||||
$acceptKey = base64_encode(sha1($acceptKey, true));
|
$acceptKey = \base64_encode(\sha1($acceptKey, true));
|
||||||
$upgrade = "HTTP/1.1 101 Switching Protocols\r\n" .
|
$upgrade = "HTTP/1.1 101 Switching Protocols\r\n" .
|
||||||
"Upgrade: websocket\r\n" .
|
"Upgrade: websocket\r\n" .
|
||||||
"Connection: Upgrade\r\n" .
|
"Connection: Upgrade\r\n" .
|
||||||
"Sec-WebSocket-Accept: $acceptKey" .
|
"Sec-WebSocket-Accept: $acceptKey" .
|
||||||
"\r\n\r\n";
|
"\r\n\r\n";
|
||||||
socket_write($client->getSocket(), $upgrade);
|
\socket_write($client->getSocket(), $upgrade);
|
||||||
$client->setHandshake(true);
|
$client->setHandshake(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -176,8 +176,8 @@ class Server extends SocketAbstract
|
||||||
public function run() : void
|
public function run() : void
|
||||||
{
|
{
|
||||||
$this->app->logger->info('Start listening...');
|
$this->app->logger->info('Start listening...');
|
||||||
socket_listen($this->sock);
|
\socket_listen($this->sock);
|
||||||
socket_set_nonblock($this->sock);
|
\socket_set_nonblock($this->sock);
|
||||||
$this->conn[] = $this->sock;
|
$this->conn[] = $this->sock;
|
||||||
|
|
||||||
$this->app->logger->info('Start running...');
|
$this->app->logger->info('Start running...');
|
||||||
|
|
@ -187,7 +187,7 @@ class Server extends SocketAbstract
|
||||||
$write = null;
|
$write = null;
|
||||||
$except = null;
|
$except = null;
|
||||||
|
|
||||||
if (socket_select($read, $write, $except, 0) < 1) {
|
if (\socket_select($read, $write, $except, 0) < 1) {
|
||||||
// error
|
// error
|
||||||
// socket_last_error();
|
// socket_last_error();
|
||||||
// socket_strerror(socket_last_error());
|
// socket_strerror(socket_last_error());
|
||||||
|
|
@ -196,11 +196,11 @@ class Server extends SocketAbstract
|
||||||
|
|
||||||
foreach ($read as $key => $socket) {
|
foreach ($read as $key => $socket) {
|
||||||
if ($this->sock === $socket) {
|
if ($this->sock === $socket) {
|
||||||
$newc = socket_accept($this->sock);
|
$newc = \socket_accept($this->sock);
|
||||||
$this->connectClient($newc);
|
$this->connectClient($newc);
|
||||||
} else {
|
} else {
|
||||||
$client = $this->clientManager->getBySocket($socket);
|
$client = $this->clientManager->getBySocket($socket);
|
||||||
$data = socket_read($socket, 1024);
|
$data = \socket_read($socket, 1024);
|
||||||
|
|
||||||
if (!$client->getHandshake()) {
|
if (!$client->getHandshake()) {
|
||||||
$this->app->logger->debug('Doing handshake...');
|
$this->app->logger->debug('Doing handshake...');
|
||||||
|
|
@ -233,8 +233,8 @@ class Server extends SocketAbstract
|
||||||
$this->app->logger->debug('Disconnecting client...');
|
$this->app->logger->debug('Disconnecting client...');
|
||||||
$client->setConnected(false);
|
$client->setConnected(false);
|
||||||
$client->setHandshake(false);
|
$client->setHandshake(false);
|
||||||
socket_shutdown($client->getSocket(), 2);
|
\socket_shutdown($client->getSocket(), 2);
|
||||||
socket_close($client->getSocket());
|
\socket_close($client->getSocket());
|
||||||
|
|
||||||
if (isset($this->conn[$client->getId()])) {
|
if (isset($this->conn[$client->getId()])) {
|
||||||
unset($this->conn[$client->getId()]);
|
unset($this->conn[$client->getId()]);
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,8 @@ abstract class SocketAbstract implements SocketInterface
|
||||||
public function close() : void
|
public function close() : void
|
||||||
{
|
{
|
||||||
if ($this->sock !== null) {
|
if ($this->sock !== null) {
|
||||||
socket_shutdown($this->sock, 2);
|
\socket_shutdown($this->sock, 2);
|
||||||
socket_close($this->sock);
|
\socket_close($this->sock);
|
||||||
$this->sock = null;
|
$this->sock = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ abstract class Enum
|
||||||
*/
|
*/
|
||||||
public static function getConstants() : array
|
public static function getConstants() : array
|
||||||
{
|
{
|
||||||
$reflect = new \ReflectionClass(get_called_class());
|
$reflect = new \ReflectionClass(\get_called_class());
|
||||||
|
|
||||||
return $reflect->getConstants();
|
return $reflect->getConstants();
|
||||||
}
|
}
|
||||||
|
|
@ -69,9 +69,9 @@ abstract class Enum
|
||||||
public static function getRandom()
|
public static function getRandom()
|
||||||
{
|
{
|
||||||
$constants = self::getConstants();
|
$constants = self::getConstants();
|
||||||
$keys = array_keys($constants);
|
$keys = \array_keys($constants);
|
||||||
|
|
||||||
return $constants[$keys[mt_rand(0, \count($constants) - 1)]];
|
return $constants[$keys[\mt_rand(0, \count($constants) - 1)]];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -91,7 +91,7 @@ abstract class Enum
|
||||||
throw new \UnexpectedValueException($name);
|
throw new \UnexpectedValueException($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return constant('static::' . $name);
|
return \constant('static::' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -107,7 +107,7 @@ abstract class Enum
|
||||||
{
|
{
|
||||||
$arr = self::getConstants();
|
$arr = self::getConstants();
|
||||||
|
|
||||||
return array_search($value, $arr);
|
return \array_search($value, $arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,7 +123,7 @@ abstract class Enum
|
||||||
*/
|
*/
|
||||||
public static function isValidName(string $name) : bool
|
public static function isValidName(string $name) : bool
|
||||||
{
|
{
|
||||||
return defined('static::' . $name);
|
return \defined('static::' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ class Iban implements \Serializable
|
||||||
*/
|
*/
|
||||||
public function prettyPrint() : string
|
public function prettyPrint() : string
|
||||||
{
|
{
|
||||||
return wordwrap($this->iban, 4, ' ', true);
|
return \wordwrap($this->iban, 4, ' ', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class SmartDateTime extends \DateTime
|
||||||
*/
|
*/
|
||||||
public function smartModify(int $y, int $m = 0, int $d = 0, int $calendar = CAL_GREGORIAN) : self
|
public function smartModify(int $y, int $m = 0, int $d = 0, int $calendar = CAL_GREGORIAN) : self
|
||||||
{
|
{
|
||||||
$yearChange = (int) floor(((int) $this->format('m') - 1 + $m) / 12);
|
$yearChange = (int) \floor(((int) $this->format('m') - 1 + $m) / 12);
|
||||||
$yearChange = ((int) $this->format('m') - 1 + $m) < 0 && ((int) $this->format('m') - 1 + $m) % 12 === 0 ? $yearChange - 1 : $yearChange;
|
$yearChange = ((int) $this->format('m') - 1 + $m) < 0 && ((int) $this->format('m') - 1 + $m) % 12 === 0 ? $yearChange - 1 : $yearChange;
|
||||||
$yearNew = (int) $this->format('Y') + $y + $yearChange;
|
$yearNew = (int) $this->format('Y') + $y + $yearChange;
|
||||||
$monthNew = ((int) $this->format('m') + $m) % 12;
|
$monthNew = ((int) $this->format('m') + $m) % 12;
|
||||||
|
|
@ -163,7 +163,7 @@ class SmartDateTime extends \DateTime
|
||||||
*/
|
*/
|
||||||
public function getFirstDayOfMonth() : int
|
public function getFirstDayOfMonth() : int
|
||||||
{
|
{
|
||||||
return getdate(\mktime(0, 0, 0, (int) $this->format('m'), 1, (int) $this->format('Y')))['wday'];
|
return \getdate(\mktime(0, 0, 0, (int) $this->format('m'), 1, (int) $this->format('Y')))['wday'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -225,7 +225,7 @@ class SmartDateTime extends \DateTime
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) date('w', $time);
|
return (int) \date('w', $time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ class Tree extends Graph
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($neighbors as $neighbor) {
|
foreach ($neighbors as $neighbor) {
|
||||||
array_merge($nodes, $this->getLevelNodes($level, $neighbor));
|
\array_merge($nodes, $this->getLevelNodes($level, $neighbor));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $nodes;
|
return $nodes;
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ final class Http implements UriInterface
|
||||||
*/
|
*/
|
||||||
public function getSubdomain() : string
|
public function getSubdomain() : string
|
||||||
{
|
{
|
||||||
$host = explode('.', $this->host);
|
$host = \explode('.', $this->host);
|
||||||
$length = \count($host) - 2;
|
$length = \count($host) - 2;
|
||||||
|
|
||||||
if ($length < 1) {
|
if ($length < 1) {
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,8 @@ class C128c extends C128Abstract
|
||||||
*/
|
*/
|
||||||
protected function generateCodeString() : string
|
protected function generateCodeString() : string
|
||||||
{
|
{
|
||||||
$keys = array_keys(self::$CODEARRAY);
|
$keys = \array_keys(self::$CODEARRAY);
|
||||||
$values = array_flip($keys);
|
$values = \array_flip($keys);
|
||||||
$codeString = '';
|
$codeString = '';
|
||||||
$length = \strlen($this->content);
|
$length = \strlen($this->content);
|
||||||
$checksum = self::$CHECKSUM;
|
$checksum = self::$CHECKSUM;
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class C39 extends C128Abstract
|
||||||
$length = \strlen($this->content);
|
$length = \strlen($this->content);
|
||||||
|
|
||||||
for ($X = 1; $X <= $length; ++$X) {
|
for ($X = 1; $X <= $length; ++$X) {
|
||||||
$codeString .= self::$CODEARRAY[substr($this->content, ($X - 1), 1)] . '1';
|
$codeString .= self::$CODEARRAY[\substr($this->content, ($X - 1), 1)] . '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $codeString;
|
return $codeString;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class LZW implements CompressionInterface
|
||||||
$dictSize = 256;
|
$dictSize = 256;
|
||||||
|
|
||||||
for ($i = 0; $i < 256; $i += 1) {
|
for ($i = 0; $i < 256; $i += 1) {
|
||||||
$dictionary[chr($i)] = $i;
|
$dictionary[\chr($i)] = $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
$length = \strlen($source);
|
$length = \strlen($source);
|
||||||
|
|
|
||||||
|
|
@ -443,7 +443,7 @@ class Repository
|
||||||
$path = $this->getDirectoryPath();
|
$path = $this->getDirectoryPath();
|
||||||
$path = \str_replace('\\', '/', $path);
|
$path = \str_replace('\\', '/', $path);
|
||||||
$path = \explode('/', $path);
|
$path = \explode('/', $path);
|
||||||
$this->name = $path[count($path) - ($this->bare ? 1 : 2)];
|
$this->name = $path[\count($path) - ($this->bare ? 1 : 2)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->name;
|
return $this->name;
|
||||||
|
|
@ -670,7 +670,7 @@ class Repository
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!feof($fh)) {
|
while (!\feof($fh)) {
|
||||||
\fgets($fh);
|
\fgets($fh);
|
||||||
$loc++;
|
$loc++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,6 @@ final class ImageUtils
|
||||||
$img = \str_replace('data:image/png;base64,', '', $img);
|
$img = \str_replace('data:image/png;base64,', '', $img);
|
||||||
$img = \str_replace(' ', '+', $img);
|
$img = \str_replace(' ', '+', $img);
|
||||||
|
|
||||||
return (string) base64_decode($img);
|
return (string) \base64_decode($img);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ class Markdown
|
||||||
$currentBlock = null;
|
$currentBlock = null;
|
||||||
|
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
if (chop($line) === '') {
|
if (\chop($line) === '') {
|
||||||
if (isset($currentBlock)) {
|
if (isset($currentBlock)) {
|
||||||
$currentBlock['interrupted'] = true;
|
$currentBlock['interrupted'] = true;
|
||||||
}
|
}
|
||||||
|
|
@ -268,9 +268,9 @@ class Markdown
|
||||||
unset($parts[0]);
|
unset($parts[0]);
|
||||||
|
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
$shortage = 4 - mb_strlen($line, 'utf-8') % 4;
|
$shortage = 4 - \mb_strlen($line, 'utf-8') % 4;
|
||||||
|
|
||||||
$line .= str_repeat(' ', $shortage);
|
$line .= \str_repeat(' ', $shortage);
|
||||||
$line .= $part;
|
$line .= $part;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -746,7 +746,7 @@ class Markdown
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chop($lineArray['text'], $lineArray['text'][0]) !== '') {
|
if (\chop($lineArray['text'], $lineArray['text'][0]) !== '') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -796,7 +796,7 @@ class Markdown
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\strpos($block['element']['text'], '|') !== false && chop($lineArray['text'], ' -:|') === '') {
|
if (\strpos($block['element']['text'], '|') !== false && \chop($lineArray['text'], ' -:|') === '') {
|
||||||
$alignments = [];
|
$alignments = [];
|
||||||
$divider = $lineArray['text'];
|
$divider = $lineArray['text'];
|
||||||
$divider = \trim($divider);
|
$divider = \trim($divider);
|
||||||
|
|
@ -899,7 +899,7 @@ class Markdown
|
||||||
$row = \trim($row);
|
$row = \trim($row);
|
||||||
$row = \trim($row, '|');
|
$row = \trim($row, '|');
|
||||||
|
|
||||||
preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches);
|
\preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches);
|
||||||
|
|
||||||
foreach ($matches[0] as $index => $cell) {
|
foreach ($matches[0] as $index => $cell) {
|
||||||
$element = [
|
$element = [
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,6 @@ class DateTime
|
||||||
{
|
{
|
||||||
$rng = new \DateTime();
|
$rng = new \DateTime();
|
||||||
|
|
||||||
return $rng->setTimestamp(mt_rand($start->getTimestamp(), $end->getTimestamp()));
|
return $rng->setTimestamp(\mt_rand($start->getTimestamp(), $end->getTimestamp()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -493,8 +493,8 @@ class Name
|
||||||
*/
|
*/
|
||||||
public static function generateName(array $type, string $origin = 'western') : string
|
public static function generateName(array $type, string $origin = 'western') : string
|
||||||
{
|
{
|
||||||
$rndType = mt_rand(0, \count($type) - 1);
|
$rndType = \mt_rand(0, \count($type) - 1);
|
||||||
|
|
||||||
return self::$names[$origin][$type[$rndType]][mt_rand(0, \count(self::$names[$origin][$type[$rndType]]) - 1)];
|
return self::$names[$origin][$type[$rndType]][\mt_rand(0, \count(self::$names[$origin][$type[$rndType]]) - 1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,12 @@ class StringUtils
|
||||||
string $charset = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
string $charset = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
) : string
|
) : string
|
||||||
{
|
{
|
||||||
$length = mt_rand($min, $max);
|
$length = \mt_rand($min, $max);
|
||||||
$charactersLength = \strlen($charset);
|
$charactersLength = \strlen($charset);
|
||||||
$randomString = '';
|
$randomString = '';
|
||||||
|
|
||||||
for ($i = 0; $i < $length; ++$i) {
|
for ($i = 0; $i < $length; ++$i) {
|
||||||
$randomString .= $charset[mt_rand(0, $charactersLength - 1)];
|
$randomString .= $charset[\mt_rand(0, $charactersLength - 1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $randomString;
|
return $randomString;
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ final class StringUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($needles as $needle) {
|
foreach ($needles as $needle) {
|
||||||
if ($needle === '' || strrpos($haystack, $needle, -strlen($haystack)) !== false) {
|
if ($needle === '' || \strrpos($haystack, $needle, -\strlen($haystack)) !== false) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -207,7 +207,7 @@ final class StringUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($needles as $needle) {
|
foreach ($needles as $needle) {
|
||||||
if ($needle === '' || (($temp = \mb_strlen($haystack) - \mb_strlen($needle)) >= 0 && mb_strpos($haystack, $needle, $temp) !== false)) {
|
if ($needle === '' || (($temp = \mb_strlen($haystack) - \mb_strlen($needle)) >= 0 && \mb_strpos($haystack, $needle, $temp) !== false)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -230,7 +230,7 @@ final class StringUtils
|
||||||
$firstChar = \mb_substr($string, 0, 1);
|
$firstChar = \mb_substr($string, 0, 1);
|
||||||
$then = \mb_substr($string, 1, $strlen - 1);
|
$then = \mb_substr($string, 1, $strlen - 1);
|
||||||
|
|
||||||
return mb_strtoupper($firstChar) . $then;
|
return \mb_strtoupper($firstChar) . $then;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -248,7 +248,7 @@ final class StringUtils
|
||||||
$firstChar = \mb_substr($string, 0, 1);
|
$firstChar = \mb_substr($string, 0, 1);
|
||||||
$then = \mb_substr($string, 1, $strlen - 1);
|
$then = \mb_substr($string, 1, $strlen - 1);
|
||||||
|
|
||||||
return mb_strtolower($firstChar) . $then;
|
return \mb_strtolower($firstChar) . $then;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class PermissionTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(6, \count(PermissionType::getConstants()));
|
self::assertEquals(6, \count(PermissionType::getConstants()));
|
||||||
self::assertEquals(PermissionType::getConstants(), array_unique(PermissionType::getConstants()));
|
self::assertEquals(PermissionType::getConstants(), \array_unique(PermissionType::getConstants()));
|
||||||
|
|
||||||
self::assertEquals(1, PermissionType::NONE);
|
self::assertEquals(1, PermissionType::NONE);
|
||||||
self::assertEquals(2, PermissionType::READ);
|
self::assertEquals(2, PermissionType::READ);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Tests\PHPUnit;
|
namespace Tests\PHPUnit;
|
||||||
|
|
||||||
spl_autoload_register('\Tests\PHPUnit\Autoloader::defaultAutoloader');
|
\spl_autoload_register('\Tests\PHPUnit\Autoloader::defaultAutoloader');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Autoloader class.
|
* Autoloader class.
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
ini_set('memory_limit', '2048M');
|
\ini_set('memory_limit', '2048M');
|
||||||
ini_set('display_errors', 1);
|
\ini_set('display_errors', 1);
|
||||||
ini_set('display_startup_errors', 1);
|
\ini_set('display_startup_errors', 1);
|
||||||
error_reporting(E_ALL);
|
\error_reporting(E_ALL);
|
||||||
|
|
||||||
if (\file_exists('vendor/autoload.php')) {
|
if (\file_exists('vendor/autoload.php')) {
|
||||||
include_once 'vendor/autoload.php';
|
include_once 'vendor/autoload.php';
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
$n = 12;
|
$n = 12;
|
||||||
$apy = FinanceFormulas::getAnnualPercentageYield($r, $n);
|
$apy = FinanceFormulas::getAnnualPercentageYield($r, $n);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 5), \round($apy, 5));
|
self::assertEquals(\round($expected, 5), \round($apy, 5));
|
||||||
self::assertEquals(round($r, 2), FinanceFormulas::getStateAnnualInterestRateOfAPY($apy, $n));
|
self::assertEquals(\round($r, 2), FinanceFormulas::getStateAnnualInterestRateOfAPY($apy, $n));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFutureValueOfAnnuity() : void
|
public function testFutureValueOfAnnuity() : void
|
||||||
|
|
@ -38,9 +38,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
$n = 5;
|
$n = 5;
|
||||||
$fva = FinanceFormulas::getFutureValueOfAnnuity($P, $r, $n);
|
$fva = FinanceFormulas::getFutureValueOfAnnuity($P, $r, $n);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 2), \round($fva, 2));
|
self::assertEquals(\round($expected, 2), \round($fva, 2));
|
||||||
self::assertEquals($n, FinanceFormulas::getNumberOfPeriodsOfFVA($fva, $P, $r));
|
self::assertEquals($n, FinanceFormulas::getNumberOfPeriodsOfFVA($fva, $P, $r));
|
||||||
self::assertEquals(round($P, 2), \round(FinanceFormulas::getPeriodicPaymentOfFVA($fva, $r, $n), 2));
|
self::assertEquals(\round($P, 2), \round(FinanceFormulas::getPeriodicPaymentOfFVA($fva, $r, $n), 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFutureValueOfAnnuityContinuousCompounding() : void
|
public function testFutureValueOfAnnuityContinuousCompounding() : void
|
||||||
|
|
@ -52,8 +52,8 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
$t = 12;
|
$t = 12;
|
||||||
$fvacc = FinanceFormulas::getFutureValueOfAnnuityConinuousCompounding($cf, $r, $t);
|
$fvacc = FinanceFormulas::getFutureValueOfAnnuityConinuousCompounding($cf, $r, $t);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 2), \round($fvacc, 2));
|
self::assertEquals(\round($expected, 2), \round($fvacc, 2));
|
||||||
self::assertEquals(round($cf, 2), \round(FinanceFormulas::getCashFlowOfFVACC($fvacc, $r, $t), 2));
|
self::assertEquals(\round($cf, 2), \round(FinanceFormulas::getCashFlowOfFVACC($fvacc, $r, $t), 2));
|
||||||
self::assertEquals($t, FinanceFormulas::getTimeOfFVACC($fvacc, $cf, $r));
|
self::assertEquals($t, FinanceFormulas::getTimeOfFVACC($fvacc, $cf, $r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,9 +66,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
$n = 5;
|
$n = 5;
|
||||||
$p = FinanceFormulas::getAnnuityPaymentPV($pv, $r, $n);
|
$p = FinanceFormulas::getAnnuityPaymentPV($pv, $r, $n);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 2), \round($p, 2));
|
self::assertEquals(\round($expected, 2), \round($p, 2));
|
||||||
self::assertEquals($n, FinanceFormulas::getNumberOfAPPV($p, $pv, $r));
|
self::assertEquals($n, FinanceFormulas::getNumberOfAPPV($p, $pv, $r));
|
||||||
self::assertEquals(round($pv, 2), \round(FinanceFormulas::getPresentValueOfAPPV($p, $r, $n), 2));
|
self::assertEquals(\round($pv, 2), \round(FinanceFormulas::getPresentValueOfAPPV($p, $r, $n), 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAnnuityPaymentFV() : void
|
public function testAnnuityPaymentFV() : void
|
||||||
|
|
@ -80,9 +80,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
$n = 5;
|
$n = 5;
|
||||||
$p = FinanceFormulas::getAnnuityPaymentFV($fv, $r, $n);
|
$p = FinanceFormulas::getAnnuityPaymentFV($fv, $r, $n);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 2), \round($p, 2));
|
self::assertEquals(\round($expected, 2), \round($p, 2));
|
||||||
self::assertEquals($n, FinanceFormulas::getNumberOfAPFV($p, $fv, $r));
|
self::assertEquals($n, FinanceFormulas::getNumberOfAPFV($p, $fv, $r));
|
||||||
self::assertEquals(round($fv, 2), \round(FinanceFormulas::getFutureValueOfAPFV($p, $r, $n), 2));
|
self::assertEquals(\round($fv, 2), \round(FinanceFormulas::getFutureValueOfAPFV($p, $r, $n), 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAnnutiyPaymentFactorPV() : void
|
public function testAnnutiyPaymentFactorPV() : void
|
||||||
|
|
@ -93,7 +93,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
$n = 5;
|
$n = 5;
|
||||||
$p = FinanceFormulas::getAnnutiyPaymentFactorPV($r, $n);
|
$p = FinanceFormulas::getAnnutiyPaymentFactorPV($r, $n);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 5), \round($p, 5));
|
self::assertEquals(\round($expected, 5), \round($p, 5));
|
||||||
self::assertEquals($n, FinanceFormulas::getNumberOfAPFPV($p, $r));
|
self::assertEquals($n, FinanceFormulas::getNumberOfAPFPV($p, $r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,9 +106,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
$n = 5;
|
$n = 5;
|
||||||
$pva = FinanceFormulas::getPresentValueOfAnnuity($P, $r, $n);
|
$pva = FinanceFormulas::getPresentValueOfAnnuity($P, $r, $n);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 2), \round($pva, 2));
|
self::assertEquals(\round($expected, 2), \round($pva, 2));
|
||||||
self::assertEquals($n, FinanceFormulas::getNumberOfPeriodsOfPVA($pva, $P, $r));
|
self::assertEquals($n, FinanceFormulas::getNumberOfPeriodsOfPVA($pva, $P, $r));
|
||||||
self::assertEquals(round($P, 2), \round(FinanceFormulas::getPeriodicPaymentOfPVA($pva, $r, $n), 2));
|
self::assertEquals(\round($P, 2), \round(FinanceFormulas::getPeriodicPaymentOfPVA($pva, $r, $n), 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPresentValueAnnuityFactor() : void
|
public function testPresentValueAnnuityFactor() : void
|
||||||
|
|
@ -119,7 +119,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
$n = 5;
|
$n = 5;
|
||||||
$p = FinanceFormulas::getPresentValueAnnuityFactor($r, $n);
|
$p = FinanceFormulas::getPresentValueAnnuityFactor($r, $n);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 4), \round($p, 4));
|
self::assertEquals(\round($expected, 4), \round($p, 4));
|
||||||
self::assertEquals($n, FinanceFormulas::getPeriodsOfPVAF($p, $r));
|
self::assertEquals($n, FinanceFormulas::getPeriodsOfPVAF($p, $r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,8 +133,8 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$PV = FinanceFormulas::getPresentValueOfAnnuityDue($P, $r, $n);
|
$PV = FinanceFormulas::getPresentValueOfAnnuityDue($P, $r, $n);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 2), \round($PV, 2));
|
self::assertEquals(\round($expected, 2), \round($PV, 2));
|
||||||
self::assertEquals(round($P, 2), FinanceFormulas::getPeriodicPaymentOfPVAD($PV, $r, $n));
|
self::assertEquals(\round($P, 2), FinanceFormulas::getPeriodicPaymentOfPVAD($PV, $r, $n));
|
||||||
self::assertEquals($n, FinanceFormulas::getPeriodsOfPVAD($PV, $P, $r));
|
self::assertEquals($n, FinanceFormulas::getPeriodsOfPVAD($PV, $P, $r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,8 +148,8 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$FV = FinanceFormulas::getFutureValueOfAnnuityDue($P, $r, $n);
|
$FV = FinanceFormulas::getFutureValueOfAnnuityDue($P, $r, $n);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 2), \round($FV, 2));
|
self::assertEquals(\round($expected, 2), \round($FV, 2));
|
||||||
self::assertEquals(round($P, 2), FinanceFormulas::getPeriodicPaymentOfFVAD($FV, $r, $n));
|
self::assertEquals(\round($P, 2), FinanceFormulas::getPeriodicPaymentOfFVAD($FV, $r, $n));
|
||||||
self::assertEquals($n, FinanceFormulas::getPeriodsOfFVAD($FV, $P, $r));
|
self::assertEquals($n, FinanceFormulas::getPeriodsOfFVAD($FV, $P, $r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,7 +198,7 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$C = \round(FinanceFormulas::getCompoundInterest($P, $r, $t), 2);
|
$C = \round(FinanceFormulas::getCompoundInterest($P, $r, $t), 2);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 2), $C);
|
self::assertEquals(\round($expected, 2), $C);
|
||||||
self::assertTrue(\abs($P - FinanceFormulas::getPrincipalOfCompundInterest($C, $r, $t)) < 0.1);
|
self::assertTrue(\abs($P - FinanceFormulas::getPrincipalOfCompundInterest($C, $r, $t)) < 0.1);
|
||||||
self::assertEquals($t, (int) \round(FinanceFormulas::getPeriodsOfCompundInterest($P, $C, $r), 0));
|
self::assertEquals($t, (int) \round(FinanceFormulas::getPeriodsOfCompundInterest($P, $C, $r), 0));
|
||||||
}
|
}
|
||||||
|
|
@ -213,8 +213,8 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$C = \round(FinanceFormulas::getContinuousCompounding($P, $r, $t), 2);
|
$C = \round(FinanceFormulas::getContinuousCompounding($P, $r, $t), 2);
|
||||||
|
|
||||||
self::assertEquals(round($expected, 2), $C);
|
self::assertEquals(\round($expected, 2), $C);
|
||||||
self::assertEquals(round($P, 2), \round(FinanceFormulas::getPrincipalOfContinuousCompounding($C, $r, $t), 2));
|
self::assertEquals(\round($P, 2), \round(FinanceFormulas::getPrincipalOfContinuousCompounding($C, $r, $t), 2));
|
||||||
self::assertTrue(\abs($t - FinanceFormulas::getPeriodsOfContinuousCompounding($P, $C, $r)) < 0.01);
|
self::assertTrue(\abs($t - FinanceFormulas::getPeriodsOfContinuousCompounding($P, $C, $r)) < 0.01);
|
||||||
self::assertTrue(\abs($r - FinanceFormulas::getRateOfContinuousCompounding($P, $C, $t)) < 0.01);
|
self::assertTrue(\abs($r - FinanceFormulas::getRateOfContinuousCompounding($P, $C, $t)) < 0.01);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,15 +29,15 @@ class NetPromoterScoreTest extends \PHPUnit\Framework\TestCase
|
||||||
$nps = new NetPromoterScore();
|
$nps = new NetPromoterScore();
|
||||||
|
|
||||||
for ($i = 0; $i < 10; ++$i) {
|
for ($i = 0; $i < 10; ++$i) {
|
||||||
$nps->add(mt_rand(0, 6));
|
$nps->add(\mt_rand(0, 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < 30; ++$i) {
|
for ($i = 0; $i < 30; ++$i) {
|
||||||
$nps->add(mt_rand(7, 8));
|
$nps->add(\mt_rand(7, 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < 60; ++$i) {
|
for ($i = 0; $i < 60; ++$i) {
|
||||||
$nps->add(mt_rand(9, 10));
|
$nps->add(\mt_rand(9, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertEquals(50, $nps->getScore());
|
self::assertEquals(50, $nps->getScore());
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testCreateMemCached() : void
|
public function testCreateMemCached() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('memcached')) {
|
if (!\extension_loaded('memcached')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The Memcached extension is not available.'
|
'The Memcached extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
@ -42,7 +42,7 @@ class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testCreateRedisCache() : void
|
public function testCreateRedisCache() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('redis')) {
|
if (!\extension_loaded('redis')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The Redis extension is not available.'
|
'The Redis extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -142,26 +142,26 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
$cache->set('key2', 'testVal2', 1);
|
$cache->set('key2', 'testVal2', 1);
|
||||||
self::assertEquals('testVal2', $cache->get('key2', 1));
|
self::assertEquals('testVal2', $cache->get('key2', 1));
|
||||||
sleep(3);
|
\sleep(3);
|
||||||
self::assertEquals(null, $cache->get('key2', 1));
|
self::assertEquals(null, $cache->get('key2', 1));
|
||||||
|
|
||||||
$cache->set('key3', 'testVal3', 1);
|
$cache->set('key3', 'testVal3', 1);
|
||||||
self::assertEquals('testVal3', $cache->get('key3', 1));
|
self::assertEquals('testVal3', $cache->get('key3', 1));
|
||||||
sleep(3);
|
\sleep(3);
|
||||||
self::assertEquals(null, $cache->get('key3', 1));
|
self::assertEquals(null, $cache->get('key3', 1));
|
||||||
|
|
||||||
$cache->set('key4', 'testVal4', 1);
|
$cache->set('key4', 'testVal4', 1);
|
||||||
self::assertFalse($cache->delete('key4', 0));
|
self::assertFalse($cache->delete('key4', 0));
|
||||||
sleep(3);
|
\sleep(3);
|
||||||
self::assertTrue($cache->delete('key4', 1));
|
self::assertTrue($cache->delete('key4', 1));
|
||||||
|
|
||||||
$cache->set('key5', 'testVal5', 10000);
|
$cache->set('key5', 'testVal5', 10000);
|
||||||
sleep(3);
|
\sleep(3);
|
||||||
self::assertFalse($cache->delete('key5', 1000000));
|
self::assertFalse($cache->delete('key5', 1000000));
|
||||||
self::assertTrue($cache->delete('key5', 1));
|
self::assertTrue($cache->delete('key5', 1));
|
||||||
|
|
||||||
$cache->set('key6', 'testVal6', 1);
|
$cache->set('key6', 'testVal6', 1);
|
||||||
sleep(2);
|
\sleep(2);
|
||||||
|
|
||||||
$cache->flush(0);
|
$cache->flush(0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
protected function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('memcached')) {
|
if (!\extension_loaded('memcached')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The Memcached extension is not available.'
|
'The Memcached extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
@ -75,7 +75,7 @@ class MemCachedTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals(5.12, $cache->get('key5'));
|
self::assertEquals(5.12, $cache->get('key5'));
|
||||||
|
|
||||||
$cache->set('key6', ['asdf', 1, true, 2.3]); // 7
|
$cache->set('key6', ['asdf', 1, true, 2.3]); // 7
|
||||||
self::assertEquals(json_encode(['asdf', 1, true, 2.3]), $cache->get('key6'));
|
self::assertEquals(\json_encode(['asdf', 1, true, 2.3]), $cache->get('key6'));
|
||||||
|
|
||||||
self::assertTrue($cache->replace('key4', 5));
|
self::assertTrue($cache->replace('key4', 5));
|
||||||
self::assertFalse($cache->replace('keyInvalid', 5));
|
self::assertFalse($cache->replace('keyInvalid', 5));
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
protected function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('redis')) {
|
if (!\extension_loaded('redis')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The Redis extension is not available.'
|
'The Redis extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
@ -77,7 +77,7 @@ class RedisCacheTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals(5.12, $cache->get('key5'));
|
self::assertEquals(5.12, $cache->get('key5'));
|
||||||
|
|
||||||
$cache->set('key6', ['asdf', 1, true, 2.3]); // 7
|
$cache->set('key6', ['asdf', 1, true, 2.3]); // 7
|
||||||
self::assertEquals(json_encode(['asdf', 1, true, 2.3]), $cache->get('key6'));
|
self::assertEquals(\json_encode(['asdf', 1, true, 2.3]), $cache->get('key6'));
|
||||||
|
|
||||||
self::assertTrue($cache->replace('key4', 5));
|
self::assertTrue($cache->replace('key4', 5));
|
||||||
self::assertFalse($cache->replace('keyInvalid', 5));
|
self::assertFalse($cache->replace('keyInvalid', 5));
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
public function testCreateMysql() : void
|
public function testCreateMysql() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('pdo_mysql')) {
|
if (!\extension_loaded('pdo_mysql')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The Mysql extension is not available.'
|
'The Mysql extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
@ -39,7 +39,7 @@ class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testCreatePostgres() : void
|
public function testCreatePostgres() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('pdo_pgsql')) {
|
if (!\extension_loaded('pdo_pgsql')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The Postresql extension is not available.'
|
'The Postresql extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
@ -55,7 +55,7 @@ class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testCreateSqlsrv() : void
|
public function testCreateSqlsrv() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('pdo_sqlsrv')) {
|
if (!\extension_loaded('pdo_sqlsrv')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The Sqlsrv extension is not available.'
|
'The Sqlsrv extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
@ -71,7 +71,7 @@ class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testCreateSqlite() : void
|
public function testCreateSqlite() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('pdo_sqlite')) {
|
if (!\extension_loaded('pdo_sqlite')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The SQLite extension is not available.'
|
'The SQLite extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class MysqlConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
protected function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('pdo_mysql')) {
|
if (!\extension_loaded('pdo_mysql')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The Mysql extension is not available.'
|
'The Mysql extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class PostgresConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
protected function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('pdo_pgsql')) {
|
if (!\extension_loaded('pdo_pgsql')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The Postresql extension is not available.'
|
'The Postresql extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class SQLiteConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
protected function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('pdo_sqlite')) {
|
if (!\extension_loaded('pdo_sqlite')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The SQLite extension is not available.'
|
'The SQLite extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class SqlServerConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
protected function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('pdo_sqlsrv')) {
|
if (!\extension_loaded('pdo_sqlsrv')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The Sqlsrv extension is not available.'
|
'The Sqlsrv extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class JoinTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(12, \count(JoinType::getConstants()));
|
self::assertEquals(12, \count(JoinType::getConstants()));
|
||||||
self::assertEquals(JoinType::getConstants(), array_unique(JoinType::getConstants()));
|
self::assertEquals(JoinType::getConstants(), \array_unique(JoinType::getConstants()));
|
||||||
|
|
||||||
self::assertEquals('JOIN', JoinType::JOIN);
|
self::assertEquals('JOIN', JoinType::JOIN);
|
||||||
self::assertEquals('LEFT JOIN', JoinType::LEFT_JOIN);
|
self::assertEquals('LEFT JOIN', JoinType::LEFT_JOIN);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class QueryTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(7, \count(QueryType::getConstants()));
|
self::assertEquals(7, \count(QueryType::getConstants()));
|
||||||
self::assertEquals(QueryType::getConstants(), array_unique(QueryType::getConstants()));
|
self::assertEquals(QueryType::getConstants(), \array_unique(QueryType::getConstants()));
|
||||||
|
|
||||||
self::assertEquals(0, QueryType::SELECT);
|
self::assertEquals(0, QueryType::SELECT);
|
||||||
self::assertEquals(1, QueryType::INSERT);
|
self::assertEquals(1, QueryType::INSERT);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class QueryTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(13, \count(QueryType::getConstants()));
|
self::assertEquals(13, \count(QueryType::getConstants()));
|
||||||
self::assertEquals(QueryType::getConstants(), array_unique(QueryType::getConstants()));
|
self::assertEquals(QueryType::getConstants(), \array_unique(QueryType::getConstants()));
|
||||||
|
|
||||||
self::assertEquals(128, QueryType::DROP_DATABASE);
|
self::assertEquals(128, QueryType::DROP_DATABASE);
|
||||||
self::assertEquals(129, QueryType::ALTER);
|
self::assertEquals(129, QueryType::ALTER);
|
||||||
|
|
|
||||||
|
|
@ -17,26 +17,26 @@ class ExtensionTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
public function testExtensionMbstring() : void
|
public function testExtensionMbstring() : void
|
||||||
{
|
{
|
||||||
self::assertTrue(extension_loaded('mbstring'));
|
self::assertTrue(\extension_loaded('mbstring'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExtensionCurl() : void
|
public function testExtensionCurl() : void
|
||||||
{
|
{
|
||||||
self::assertTrue(extension_loaded('curl'));
|
self::assertTrue(\extension_loaded('curl'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExtensionImap() : void
|
public function testExtensionImap() : void
|
||||||
{
|
{
|
||||||
self::assertTrue(extension_loaded('imap'));
|
self::assertTrue(\extension_loaded('imap'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExtensionPdo() : void
|
public function testExtensionPdo() : void
|
||||||
{
|
{
|
||||||
self::assertTrue(extension_loaded('pdo'));
|
self::assertTrue(\extension_loaded('pdo'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExtensionGD() : void
|
public function testExtensionGD() : void
|
||||||
{
|
{
|
||||||
self::assertTrue(extension_loaded('gd') || extension_loaded('gd2'));
|
self::assertTrue(\extension_loaded('gd') || \extension_loaded('gd2'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,6 @@ class ISO3166CharEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
self::assertTrue($ok);
|
||||||
self::assertEquals(\count($enum), \count(array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,6 @@ class ISO3166NameEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
$enum = ISO3166NameEnum::getConstants();
|
$enum = ISO3166NameEnum::getConstants();
|
||||||
self::assertEquals(\count($enum), \count(array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,6 @@ class ISO3166NumEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
self::assertTrue($ok);
|
||||||
self::assertEquals(\count($enum), \count(array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,6 @@ class ISO3166TwoEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
self::assertTrue($ok);
|
||||||
self::assertEquals(\count($countryCodes), \count(array_unique($countryCodes)));
|
self::assertEquals(\count($countryCodes), \count(\array_unique($countryCodes)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,6 @@ class ISO4217CharEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
self::assertTrue($ok);
|
||||||
self::assertEquals(\count($enum), \count(array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,6 @@ class ISO4217EnumTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
$enum = ISO4217Enum::getConstants();
|
$enum = ISO4217Enum::getConstants();
|
||||||
self::assertEquals(\count($enum), \count(array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,6 @@ class ISO4217NumEnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
self::assertTrue($ok);
|
||||||
self::assertEquals(\count($enum), \count(array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,6 @@ class ISO639EnumTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
$enum = ISO639Enum::getConstants();
|
$enum = ISO639Enum::getConstants();
|
||||||
self::assertEquals(\count($enum), \count(array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,6 @@ class ISO639x1EnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
self::assertTrue($ok);
|
||||||
self::assertEquals(\count($enum), \count(array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,6 @@ class ISO639x2EnumTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
self::assertTrue($ok);
|
self::assertTrue($ok);
|
||||||
self::assertEquals(\count($enum), \count(array_unique($enum)));
|
self::assertEquals(\count($enum), \count(\array_unique($enum)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,6 @@ class TimeZoneEnumArrayTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(\count(TimeZoneEnumArray::getConstants()), \count(array_unique(TimeZoneEnumArray::getConstants())));
|
self::assertEquals(\count(TimeZoneEnumArray::getConstants()), \count(\array_unique(TimeZoneEnumArray::getConstants())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,15 +26,15 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertObjectHasAttribute('fp', $log);
|
self::assertObjectHasAttribute('fp', $log);
|
||||||
self::assertObjectHasAttribute('path', $log);
|
self::assertObjectHasAttribute('path', $log);
|
||||||
|
|
||||||
if (\file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
if (\file_exists(__DIR__ . '/' . \date('Y-m-d') . '.log')) {
|
||||||
\unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
\unlink(__DIR__ . '/' . \date('Y-m-d') . '.log');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefault() : void
|
public function testDefault() : void
|
||||||
{
|
{
|
||||||
if (\file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
if (\file_exists(__DIR__ . '/' . \date('Y-m-d') . '.log')) {
|
||||||
\unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
\unlink(__DIR__ . '/' . \date('Y-m-d') . '.log');
|
||||||
}
|
}
|
||||||
|
|
||||||
$log = FileLogger::getInstance(__DIR__);
|
$log = FileLogger::getInstance(__DIR__);
|
||||||
|
|
@ -43,8 +43,8 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals([], $log->get());
|
self::assertEquals([], $log->get());
|
||||||
self::assertEquals([], $log->getByLine());
|
self::assertEquals([], $log->getByLine());
|
||||||
|
|
||||||
if (\file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
if (\file_exists(__DIR__ . '/' . \date('Y-m-d') . '.log')) {
|
||||||
\unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
\unlink(__DIR__ . '/' . \date('Y-m-d') . '.log');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals(2, $log->countLogs()['debug'] ?? 0);
|
self::assertEquals(2, $log->countLogs()['debug'] ?? 0);
|
||||||
|
|
||||||
self::assertEquals(['0.0.0.0' => 9], $log->getHighestPerpetrator());
|
self::assertEquals(['0.0.0.0' => 9], $log->getHighestPerpetrator());
|
||||||
self::assertEquals([6, 7, 8, 9, 10], array_keys($log->get(5, 1)));
|
self::assertEquals([6, 7, 8, 9, 10], \array_keys($log->get(5, 1)));
|
||||||
self::assertEquals('alert', $log->getByLine(2)['level']);
|
self::assertEquals('alert', $log->getByLine(2)['level']);
|
||||||
|
|
||||||
\ob_start();
|
\ob_start();
|
||||||
|
|
@ -129,7 +129,7 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase
|
||||||
'line' => 11,
|
'line' => 11,
|
||||||
'file' => self::class,
|
'file' => self::class,
|
||||||
]);
|
]);
|
||||||
$ob = ob_get_clean();
|
$ob = \ob_get_clean();
|
||||||
|
|
||||||
// test without output
|
// test without output
|
||||||
$log->console(FileLogger::MSG_FULL, false, [
|
$log->console(FileLogger::MSG_FULL, false, [
|
||||||
|
|
@ -142,13 +142,13 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
\ob_start();
|
\ob_start();
|
||||||
$log->console('test', true);
|
$log->console('test', true);
|
||||||
$ob = ob_get_clean();
|
$ob = \ob_get_clean();
|
||||||
self::assertEquals(\date('[Y-m-d H:i:s] ') . "test\r\n", $ob);
|
self::assertEquals(\date('[Y-m-d H:i:s] ') . "test\r\n", $ob);
|
||||||
|
|
||||||
\unlink(__DIR__ . '/test.log');
|
\unlink(__DIR__ . '/test.log');
|
||||||
|
|
||||||
if (\file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
if (\file_exists(__DIR__ . '/' . \date('Y-m-d') . '.log')) {
|
||||||
\unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
\unlink(__DIR__ . '/' . \date('Y-m-d') . '.log');
|
||||||
}
|
}
|
||||||
|
|
||||||
\ob_clean();
|
\ob_clean();
|
||||||
|
|
@ -179,8 +179,8 @@ class FileLoggerTest extends \PHPUnit\Framework\TestCase
|
||||||
\unlink(__DIR__ . '/test.log');
|
\unlink(__DIR__ . '/test.log');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\file_exists(__DIR__ . '/' . date('Y-m-d') . '.log')) {
|
if (\file_exists(__DIR__ . '/' . \date('Y-m-d') . '.log')) {
|
||||||
\unlink(__DIR__ . '/' . date('Y-m-d') . '.log');
|
\unlink(__DIR__ . '/' . \date('Y-m-d') . '.log');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ class EigenvalueDecompositionTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEqualsWithDelta([0, 2, 5], $eig->getRealEigenvalues()->toArray(), 0.2);
|
self::assertEqualsWithDelta([0, 2, 5], $eig->getRealEigenvalues()->toArray(), 0.2);
|
||||||
|
|
||||||
self::assertEqualsWithDelta([
|
self::assertEqualsWithDelta([
|
||||||
[0, 2/sqrt(6), 1/sqrt(3)],
|
[0, 2/\sqrt(6), 1/\sqrt(3)],
|
||||||
[1/sqrt(2), -1/sqrt(6), 1/sqrt(3)],
|
[1/\sqrt(2), -1/\sqrt(6), 1/\sqrt(3)],
|
||||||
[-1/sqrt(2), -1/sqrt(6), 1/sqrt(3)],
|
[-1/\sqrt(2), -1/\sqrt(6), 1/\sqrt(3)],
|
||||||
], $eig->getV()->toArray(), 0.2);
|
], $eig->getV()->toArray(), 0.2);
|
||||||
|
|
||||||
self::assertEqualsWithDelta([
|
self::assertEqualsWithDelta([
|
||||||
|
|
@ -60,9 +60,9 @@ class EigenvalueDecompositionTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEqualsWithDelta([-5, 3, 6], $eig->getRealEigenvalues()->toArray(), 0.2);
|
self::assertEqualsWithDelta([-5, 3, 6], $eig->getRealEigenvalues()->toArray(), 0.2);
|
||||||
|
|
||||||
self::assertEqualsWithDelta([
|
self::assertEqualsWithDelta([
|
||||||
[-sqrt(2/3), sqrt(2/7), -1/sqrt(293)],
|
[-\sqrt(2/3), \sqrt(2/7), -1/\sqrt(293)],
|
||||||
[-1/sqrt(6), -3/sqrt(14), -6/sqrt(293)],
|
[-1/\sqrt(6), -3/\sqrt(14), -6/\sqrt(293)],
|
||||||
[1/sqrt(6), -1/sqrt(14), -16/sqrt(293)],
|
[1/\sqrt(6), -1/\sqrt(14), -16/\sqrt(293)],
|
||||||
], $eig->getV()->toArray(), 0.2);
|
], $eig->getV()->toArray(), 0.2);
|
||||||
|
|
||||||
self::assertEqualsWithDelta([
|
self::assertEqualsWithDelta([
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class NumberTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(9, \count(NumberType::getConstants()));
|
self::assertEquals(9, \count(NumberType::getConstants()));
|
||||||
self::assertEquals(NumberType::getConstants(), array_unique(NumberType::getConstants()));
|
self::assertEquals(NumberType::getConstants(), \array_unique(NumberType::getConstants()));
|
||||||
|
|
||||||
self::assertEquals(0, NumberType::N_INTEGER);
|
self::assertEquals(0, NumberType::N_INTEGER);
|
||||||
self::assertEquals(1, NumberType::N_NATURAL);
|
self::assertEquals(1, NumberType::N_NATURAL);
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testMode() : void
|
public function testMode() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(max(5 - 2, 0), ChiSquaredDistribution::getMode(5));
|
self::assertEquals(\max(5 - 2, 0), ChiSquaredDistribution::getMode(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMean() : void
|
public function testMean() : void
|
||||||
|
|
@ -74,7 +74,7 @@ class ChiSquaredDistributionTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$df = 5;
|
$df = 5;
|
||||||
|
|
||||||
self::assertEquals(sqrt(8 / $df), ChiSquaredDistribution::getSkewness($df));
|
self::assertEquals(\sqrt(8 / $df), ChiSquaredDistribution::getSkewness($df));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExKurtosis() : void
|
public function testExKurtosis() : void
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class ExponentialDistributionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testMedian() : void
|
public function testMedian() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(1/3 * log(2), ExponentialDistribution::getMedian(3));
|
self::assertEquals(1/3 * \log(2), ExponentialDistribution::getMedian(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMgf() : void
|
public function testMgf() : void
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class GeometricDistributionTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$p = 0.3;
|
$p = 0.3;
|
||||||
|
|
||||||
self::assertEquals((2 - $p) / sqrt(1 - $p), GeometricDistribution::getSkewness($p));
|
self::assertEquals((2 - $p) / \sqrt(1 - $p), GeometricDistribution::getSkewness($p));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExKurtosis() : void
|
public function testExKurtosis() : void
|
||||||
|
|
@ -70,6 +70,6 @@ class GeometricDistributionTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$p = 0.3;
|
$p = 0.3;
|
||||||
|
|
||||||
self::assertEquals(ceil(-1 / log(1 - $p, 2)), GeometricDistribution::getMedian($p));
|
self::assertEquals(\ceil(-1 / \log(1 - $p, 2)), GeometricDistribution::getMedian($p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
$l = 4.6;
|
$l = 4.6;
|
||||||
|
|
||||||
self::assertEquals(1 / sqrt($l), PoissonDistribution::getSkewness($l));
|
self::assertEquals(1 / \sqrt($l), PoissonDistribution::getSkewness($l));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExKurtosis() : void
|
public function testExKurtosis() : void
|
||||||
|
|
@ -87,6 +87,6 @@ class PoissonDistributionTest extends \PHPUnit\Framework\TestCase
|
||||||
$l = 4.6;
|
$l = 4.6;
|
||||||
$t = 3;
|
$t = 3;
|
||||||
|
|
||||||
self::assertEquals(exp($l * (\exp($t) - 1)), PoissonDistribution::getMgf($l, $t));
|
self::assertEquals(\exp($l * (\exp($t) - 1)), PoissonDistribution::getMgf($l, $t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class BrowserTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(12, BrowserType::count());
|
self::assertEquals(12, BrowserType::count());
|
||||||
self::assertEquals(BrowserType::getConstants(), array_unique(BrowserType::getConstants()));
|
self::assertEquals(BrowserType::getConstants(), \array_unique(BrowserType::getConstants()));
|
||||||
|
|
||||||
self::assertEquals('msie', BrowserType::IE);
|
self::assertEquals('msie', BrowserType::IE);
|
||||||
self::assertEquals('edge', BrowserType::EDGE);
|
self::assertEquals('edge', BrowserType::EDGE);
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,6 @@ class OSTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(24, \count(OSType::getConstants()));
|
self::assertEquals(24, \count(OSType::getConstants()));
|
||||||
self::assertEquals(OSType::getConstants(), array_unique(OSType::getConstants()));
|
self::assertEquals(OSType::getConstants(), \array_unique(OSType::getConstants()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class RequestMethodTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(6, \count(RequestMethod::getConstants()));
|
self::assertEquals(6, \count(RequestMethod::getConstants()));
|
||||||
self::assertEquals(RequestMethod::getConstants(), array_unique(RequestMethod::getConstants()));
|
self::assertEquals(RequestMethod::getConstants(), \array_unique(RequestMethod::getConstants()));
|
||||||
|
|
||||||
self::assertEquals('GET', RequestMethod::GET);
|
self::assertEquals('GET', RequestMethod::GET);
|
||||||
self::assertEquals('POST', RequestMethod::POST);
|
self::assertEquals('POST', RequestMethod::POST);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class RequestStatusCodeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(55, \count(RequestStatusCode::getConstants()));
|
self::assertEquals(55, \count(RequestStatusCode::getConstants()));
|
||||||
self::assertEquals(RequestStatusCode::getConstants(), array_unique(RequestStatusCode::getConstants()));
|
self::assertEquals(RequestStatusCode::getConstants(), \array_unique(RequestStatusCode::getConstants()));
|
||||||
|
|
||||||
self::assertEquals(100, RequestStatusCode::R_100);
|
self::assertEquals(100, RequestStatusCode::R_100);
|
||||||
self::assertEquals(101, RequestStatusCode::R_101);
|
self::assertEquals(101, RequestStatusCode::R_101);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class RequestStatusTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(55, \count(RequestStatus::getConstants()));
|
self::assertEquals(55, \count(RequestStatus::getConstants()));
|
||||||
self::assertEquals(RequestStatus::getConstants(), array_unique(RequestStatus::getConstants()));
|
self::assertEquals(RequestStatus::getConstants(), \array_unique(RequestStatus::getConstants()));
|
||||||
|
|
||||||
self::assertEquals('Continue', RequestStatus::R_100);
|
self::assertEquals('Continue', RequestStatus::R_100);
|
||||||
self::assertEquals('Switching Protocols', RequestStatus::R_101);
|
self::assertEquals('Switching Protocols', RequestStatus::R_101);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class DomActionTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(9, \count(DomAction::getConstants()));
|
self::assertEquals(9, \count(DomAction::getConstants()));
|
||||||
self::assertEquals(DomAction::getConstants(), array_unique(DomAction::getConstants()));
|
self::assertEquals(DomAction::getConstants(), \array_unique(DomAction::getConstants()));
|
||||||
|
|
||||||
self::assertEquals(0, DomAction::CREATE_BEFORE);
|
self::assertEquals(0, DomAction::CREATE_BEFORE);
|
||||||
self::assertEquals(1, DomAction::CREATE_AFTER);
|
self::assertEquals(1, DomAction::CREATE_AFTER);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class NotifyTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(5, \count(NotifyType::getConstants()));
|
self::assertEquals(5, \count(NotifyType::getConstants()));
|
||||||
self::assertEquals(NotifyType::getConstants(), array_unique(NotifyType::getConstants()));
|
self::assertEquals(NotifyType::getConstants(), \array_unique(NotifyType::getConstants()));
|
||||||
|
|
||||||
self::assertEquals(0, NotifyType::BINARY);
|
self::assertEquals(0, NotifyType::BINARY);
|
||||||
self::assertEquals(1, NotifyType::INFO);
|
self::assertEquals(1, NotifyType::INFO);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
public static function setUpBeforeClass() : void
|
public static function setUpBeforeClass() : void
|
||||||
{
|
{
|
||||||
if (\file_exists(__DIR__ . '/testPackage.zip')) {
|
if (\file_exists(__DIR__ . '/testPackage.zip')) {
|
||||||
unlink(__DIR__ . '/testPackage.zip');
|
\unlink(__DIR__ . '/testPackage.zip');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\file_exists(__DIR__ . '/testPackageExtracted')) {
|
if (\file_exists(__DIR__ . '/testPackageExtracted')) {
|
||||||
|
|
@ -34,7 +34,7 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\file_exists(__DIR__ . '/public.key')) {
|
if (\file_exists(__DIR__ . '/public.key')) {
|
||||||
unlink(__DIR__ . '/public.key');
|
\unlink(__DIR__ . '/public.key');
|
||||||
}
|
}
|
||||||
|
|
||||||
// create keys
|
// create keys
|
||||||
|
|
@ -61,7 +61,7 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash = \sodium_crypto_generichash_final($state);
|
$hash = \sodium_crypto_generichash_final($state);
|
||||||
$signature = sodium_crypto_sign_detached($hash, $alice_sign_secretkey);
|
$signature = \sodium_crypto_sign_detached($hash, $alice_sign_secretkey);
|
||||||
|
|
||||||
\file_put_contents(__DIR__ . '/testPackage/package.cert', $signature);
|
\file_put_contents(__DIR__ . '/testPackage/package.cert', $signature);
|
||||||
\file_put_contents(__DIR__ . '/public.key', $alice_sign_publickey);
|
\file_put_contents(__DIR__ . '/public.key', $alice_sign_publickey);
|
||||||
|
|
@ -133,7 +133,7 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
public static function tearDownAfterClass() : void
|
public static function tearDownAfterClass() : void
|
||||||
{
|
{
|
||||||
if (\file_exists(__DIR__ . '/testPackage.zip')) {
|
if (\file_exists(__DIR__ . '/testPackage.zip')) {
|
||||||
unlink(__DIR__ . '/testPackage.zip');
|
\unlink(__DIR__ . '/testPackage.zip');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\file_exists(__DIR__ . '/testPackageExtracted')) {
|
if (\file_exists(__DIR__ . '/testPackageExtracted')) {
|
||||||
|
|
@ -144,9 +144,9 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\file_exists(__DIR__ . '/public.key')) {
|
if (\file_exists(__DIR__ . '/public.key')) {
|
||||||
unlink(__DIR__ . '/public.key');
|
\unlink(__DIR__ . '/public.key');
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(__DIR__ . '/testPackage/package.cert', '');
|
\file_put_contents(__DIR__ . '/testPackage/package.cert', '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,6 @@ class RouteVerbTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnumUnique() : void
|
public function testEnumUnique() : void
|
||||||
{
|
{
|
||||||
$values = RouteVerb::getConstants();
|
$values = RouteVerb::getConstants();
|
||||||
self::assertEquals(\count($values), array_sum(array_count_values($values)));
|
self::assertEquals(\count($values), \array_sum(\array_count_values($values)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
function noDeprecated()
|
function noDeprecated()
|
||||||
{
|
{
|
||||||
return is_string('');
|
return \is_string('');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,8 @@ class SmartDateTimeTest extends \PHPUnit\Framework\TestCase
|
||||||
$expected = new \DateTime('now');
|
$expected = new \DateTime('now');
|
||||||
$obj = SmartDateTime::createFromDateTime($expected);
|
$obj = SmartDateTime::createFromDateTime($expected);
|
||||||
self::assertEquals($expected->format('Y-m-d H:i:s'), $obj->format('Y-m-d H:i:s'));
|
self::assertEquals($expected->format('Y-m-d H:i:s'), $obj->format('Y-m-d H:i:s'));
|
||||||
self::assertEquals(\date("Y-m-t", strtotime($expected->format('Y-m-d'))), $obj->getEndOfMonth()->format('Y-m-d'));
|
self::assertEquals(\date("Y-m-t", \strtotime($expected->format('Y-m-d'))), $obj->getEndOfMonth()->format('Y-m-d'));
|
||||||
self::assertEquals(\date("Y-m-01", strtotime($expected->format('Y-m-d'))), $obj->getStartOfMonth()->format('Y-m-d'));
|
self::assertEquals(\date("Y-m-01", \strtotime($expected->format('Y-m-d'))), $obj->getStartOfMonth()->format('Y-m-d'));
|
||||||
|
|
||||||
self::assertFalse((new SmartDateTime('2103-07-20'))->isLeapYear());
|
self::assertFalse((new SmartDateTime('2103-07-20'))->isLeapYear());
|
||||||
self::assertTrue((new SmartDateTime('2104-07-20'))->isLeapYear());
|
self::assertTrue((new SmartDateTime('2104-07-20'))->isLeapYear());
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class ContentPutModeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(4, \count(ContentPutMode::getConstants()));
|
self::assertEquals(4, \count(ContentPutMode::getConstants()));
|
||||||
self::assertEquals(ContentPutMode::getConstants(), array_unique(ContentPutMode::getConstants()));
|
self::assertEquals(ContentPutMode::getConstants(), \array_unique(ContentPutMode::getConstants()));
|
||||||
|
|
||||||
self::assertEquals(1, ContentPutMode::APPEND);
|
self::assertEquals(1, ContentPutMode::APPEND);
|
||||||
self::assertEquals(2, ContentPutMode::PREPEND);
|
self::assertEquals(2, ContentPutMode::PREPEND);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class ExtensionTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnums() : void
|
public function testEnums() : void
|
||||||
{
|
{
|
||||||
self::assertEquals(11, \count(ExtensionType::getConstants()));
|
self::assertEquals(11, \count(ExtensionType::getConstants()));
|
||||||
self::assertEquals(ExtensionType::getConstants(), array_unique(ExtensionType::getConstants()));
|
self::assertEquals(ExtensionType::getConstants(), \array_unique(ExtensionType::getConstants()));
|
||||||
|
|
||||||
self::assertEquals(1, ExtensionType::UNKNOWN);
|
self::assertEquals(1, ExtensionType::UNKNOWN);
|
||||||
self::assertEquals(2, ExtensionType::CODE);
|
self::assertEquals(2, ExtensionType::CODE);
|
||||||
|
|
|
||||||
1
tests/System/File/Ftp/test.txt
Normal file
1
tests/System/File/Ftp/test.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
test5test3test4
|
||||||
|
|
@ -33,7 +33,7 @@ class SystemUtilsTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals(0, SystemUtils::getRAMUsage());
|
self::assertEquals(0, SystemUtils::getRAMUsage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stristr(PHP_OS, 'WIN')) {
|
if (!\stristr(PHP_OS, 'WIN')) {
|
||||||
self::assertGreaterThan(0, SystemUtils::getRAMUsage());
|
self::assertGreaterThan(0, SystemUtils::getRAMUsage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,6 @@ class UriSchemeTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testEnumUnique() : void
|
public function testEnumUnique() : void
|
||||||
{
|
{
|
||||||
$values = UriScheme::getConstants();
|
$values = UriScheme::getConstants();
|
||||||
self::assertEquals(\count($values), array_sum(array_count_values($values)));
|
self::assertEquals(\count($values), \array_sum(\array_count_values($values)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class C128aTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
protected function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('gd')) {
|
if (!\extension_loaded('gd')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The GD extension is not available.'
|
'The GD extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class C128bTest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
protected function setUp() : void
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
if (!extension_loaded('gd')) {
|
if (!\extension_loaded('gd')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The GD extension is not available.'
|
'The GD extension is not available.'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user