diff --git a/Account/Account.php b/Account/Account.php index efed51bb9..e0d24248f 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Account; @@ -136,7 +136,7 @@ class Account implements ArrayableInterface, \JsonSerializable /** * Account type. * - * @var AccountType|int + * @var int * @since 1.0.0 */ protected $type = AccountType::USER; @@ -144,7 +144,7 @@ class Account implements ArrayableInterface, \JsonSerializable /** * Account status. * - * @var AccountStatus|int + * @var int * @since 1.0.0 */ protected $status = AccountStatus::INACTIVE; @@ -324,8 +324,8 @@ class Account implements ArrayableInterface, \JsonSerializable { $app = isset($app) ? strtolower($app) : $app; - foreach($this->permissions as $p) { - if(($p->getUnit() === $unit || $p->getUnit() === null || !isset($unit)) + foreach ($this->permissions as $p) { + if (($p->getUnit() === $unit || $p->getUnit() === null || !isset($unit)) && ($p->getApp() === $app || $p->getApp() === null || !isset($app)) && ($p->getModule() === $module || $p->getModule() === null || !isset($module)) && ($p->getType() === $type || $p->getType() === null || !isset($type)) @@ -560,7 +560,7 @@ class Account implements ArrayableInterface, \JsonSerializable */ public function generatePassword(string $password) /* : void */ { - $this->password = password_hash($password, PASSWORD_DEFAULT); + $this->password = \password_hash($password, \PASSWORD_DEFAULT); } /** @@ -624,8 +624,8 @@ class Account implements ArrayableInterface, \JsonSerializable /** * Json serialize. - * - * @return string + * + * @return array * * @since 1.0.0 */ diff --git a/Account/AccountManager.php b/Account/AccountManager.php index 8457c5e02..181d393f5 100644 --- a/Account/AccountManager.php +++ b/Account/AccountManager.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Account; diff --git a/Account/AccountStatus.php b/Account/AccountStatus.php index e8d8efd75..36a3de54a 100644 --- a/Account/AccountStatus.php +++ b/Account/AccountStatus.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Account; @@ -28,8 +28,8 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class AccountStatus extends Enum { - /* public */ const ACTIVE = 1; - /* public */ const INACTIVE = 2; - /* public */ const TIMEOUT = 3; - /* public */ const BANNED = 4; + /* public */ const ACTIVE = 1; + /* public */ const INACTIVE = 2; + /* public */ const TIMEOUT = 3; + /* public */ const BANNED = 4; } diff --git a/Account/AccountType.php b/Account/AccountType.php index 93a963465..ebe6d0df1 100644 --- a/Account/AccountType.php +++ b/Account/AccountType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Account; @@ -28,6 +28,6 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class AccountType extends Enum { - /* public */ const USER = 0; - /* public */ const GROUP = 1; + /* public */ const USER = 0; + /* public */ const GROUP = 1; } diff --git a/Account/Group.php b/Account/Group.php index 46f58c16d..f70189590 100644 --- a/Account/Group.php +++ b/Account/Group.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Account; @@ -208,7 +208,7 @@ class Group implements ArrayableInterface, \JsonSerializable /** * Json serialize. * - * @return string + * @return array * * @since 1.0.0 */ diff --git a/Account/GroupStatus.php b/Account/GroupStatus.php index 0af5c9655..c15ddd2fb 100644 --- a/Account/GroupStatus.php +++ b/Account/GroupStatus.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Account; @@ -28,7 +28,7 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class GroupStatus extends Enum { - /* public */ const ACTIVE = 1; - /* public */ const INACTIVE = 2; - /* public */ const HIDDEN = 4; + /* public */ const ACTIVE = 1; + /* public */ const INACTIVE = 2; + /* public */ const HIDDEN = 4; } diff --git a/Account/NullAccount.php b/Account/NullAccount.php index 20d49d87e..9700b7c6d 100644 --- a/Account/NullAccount.php +++ b/Account/NullAccount.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Account; diff --git a/Account/PermissionAbstract.php b/Account/PermissionAbstract.php index 13a7312f6..d8eb1cfe8 100644 --- a/Account/PermissionAbstract.php +++ b/Account/PermissionAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Account; @@ -340,7 +340,7 @@ class PermissionAbstract * * @param int $permission Permission * - * @return void + * @return bool * * @since 1.0.0 */ diff --git a/Account/PermissionType.php b/Account/PermissionType.php index 29d6059a1..d6b4122f0 100644 --- a/Account/PermissionType.php +++ b/Account/PermissionType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Account; diff --git a/Algorithm/AlgorithmType.php b/Algorithm/AlgorithmType.php index ee1d0841d..57b1c37fb 100644 --- a/Algorithm/AlgorithmType.php +++ b/Algorithm/AlgorithmType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Algorithm; diff --git a/Algorithm/Knappsack/Backpack.php b/Algorithm/Knappsack/Backpack.php index ddd220cbc..7bc983eaf 100644 --- a/Algorithm/Knappsack/Backpack.php +++ b/Algorithm/Knappsack/Backpack.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Algorithm\Knappsack; use phpOMS\Algorithm\AlgorithmType; @@ -44,7 +44,7 @@ class Backpack public function addPopulationItem(ItemInterface $item) : bool { - if(isset($this->population[$item->getId()])) { + if (isset($this->population[$item->getId()])) { return false; } @@ -75,7 +75,7 @@ class Backpack public function pack(int $type) { - switch($type) { + switch ($type) { case AlgorithmType::BRUTEFORCE: return $this->bruteforce(); default: diff --git a/Algorithm/Knappsack/ItemInterface.php b/Algorithm/Knappsack/ItemInterface.php index 0966fc09b..d01ec0ddc 100644 --- a/Algorithm/Knappsack/ItemInterface.php +++ b/Algorithm/Knappsack/ItemInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Algorithm\Knappsack; diff --git a/ApplicationAbstract.php b/ApplicationAbstract.php index 204f80302..6c106eccf 100644 --- a/ApplicationAbstract.php +++ b/ApplicationAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS; @@ -145,7 +145,7 @@ class ApplicationAbstract */ public function __set($name, $value) { - if(!empty($this->$name)) { + if (!empty($this->$name)) { return; } diff --git a/Asset/AssetManager.php b/Asset/AssetManager.php index f6bb7ef07..f93dcc61b 100644 --- a/Asset/AssetManager.php +++ b/Asset/AssetManager.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Asset; diff --git a/Asset/AssetType.php b/Asset/AssetType.php index 95fd69919..442d2bb2c 100644 --- a/Asset/AssetType.php +++ b/Asset/AssetType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Asset; @@ -28,7 +28,7 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class AssetType extends Enum { - /* public */ const CSS = 0; - /* public */ const JS = 1; - /* public */ const JSLATE = 2; + /* public */ const CSS = 0; + /* public */ const JS = 1; + /* public */ const JSLATE = 2; } diff --git a/Auth/Auth.php b/Auth/Auth.php index 0f1a06395..91bdf118d 100644 --- a/Auth/Auth.php +++ b/Auth/Auth.php @@ -11,11 +11,10 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Auth; -use phpOMS\DataStorage\Database\Connection\ConnectionAbstract; use phpOMS\DataStorage\Session\SessionInterface; /** diff --git a/Auth/LoginReturnType.php b/Auth/LoginReturnType.php index b18aa8db0..4f755f760 100644 --- a/Auth/LoginReturnType.php +++ b/Auth/LoginReturnType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Auth; diff --git a/AutoloadException.php b/AutoloadException.php index e7ff43e8c..9ba07218f 100644 --- a/AutoloadException.php +++ b/AutoloadException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS; @@ -31,7 +31,7 @@ class AutoloadException extends \RuntimeException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/Autoloader.php b/Autoloader.php index 8a67bc84d..f981cf889 100644 --- a/Autoloader.php +++ b/Autoloader.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS; @@ -47,7 +47,7 @@ class Autoloader $class = ltrim($class, '\\'); $class = str_replace(['_', '\\'], '/', $class); - if(!file_exists($path = __DIR__ . '/../' . $class . '.php')) { + if (!file_exists($path = __DIR__ . '/../' . $class . '.php')) { return; } diff --git a/Business/Finance/Depreciation.php b/Business/Finance/Depreciation.php index b6f89b96e..ff3531b11 100644 --- a/Business/Finance/Depreciation.php +++ b/Business/Finance/Depreciation.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance; @@ -29,7 +29,7 @@ class Depreciation public static function getArithmeticProgressivDepreciationRate(float $start, int $duration) : float { - return $start / ($duration * ($duration+1) / 2); + return $start / ($duration * ($duration + 1) / 2); } public static function getArithmeticProgressivDepreciationInT(float $start, int $duration, int $t) : float @@ -44,7 +44,7 @@ class Depreciation public static function getGeometicProgressivDepreciationRate(float $start, float $residual, int $duration) : float { - return (1-pow($residual / $start, 1 / $duration)); + return (1 - pow($residual / $start, 1 / $duration)); } public static function getGeometicDegressivDepreciationInT(float $start, float $residual, int $duration, int $t) : float diff --git a/Business/Finance/FinanceFormulas.php b/Business/Finance/FinanceFormulas.php index c71c110ac..7a311317a 100644 --- a/Business/Finance/FinanceFormulas.php +++ b/Business/Finance/FinanceFormulas.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance; @@ -754,6 +754,20 @@ class FinanceFormulas return log(2) / log(1 + $r); } + /** + * Get rate to dobule + * + * @param float $t Time in which to double investment + * + * @return float + * + * @since 1.0.0 + */ + public static function getDoublingRate(float $t) : float + { + return exp(log(2) / $t) - 1; + } + /** * Doubling Time - Continuous Compounding * diff --git a/Business/Finance/Forecasting/AR.php b/Business/Finance/Forecasting/AR.php index 33a693b69..4b0a6703c 100644 --- a/Business/Finance/Forecasting/AR.php +++ b/Business/Finance/Forecasting/AR.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; class AR diff --git a/Business/Finance/Forecasting/ARCH.php b/Business/Finance/Forecasting/ARCH.php index 4c9edf6f6..990f05800 100644 --- a/Business/Finance/Forecasting/ARCH.php +++ b/Business/Finance/Forecasting/ARCH.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; class ARCH diff --git a/Business/Finance/Forecasting/ARFIMA.php b/Business/Finance/Forecasting/ARFIMA.php index 0b674419e..8f4a769ec 100644 --- a/Business/Finance/Forecasting/ARFIMA.php +++ b/Business/Finance/Forecasting/ARFIMA.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; class ARFIMA diff --git a/Business/Finance/Forecasting/ARIMA.php b/Business/Finance/Forecasting/ARIMA.php index 06155e65e..b0172121d 100644 --- a/Business/Finance/Forecasting/ARIMA.php +++ b/Business/Finance/Forecasting/ARIMA.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; use phpOMS\Math\Statistic\Average; diff --git a/Business/Finance/Forecasting/ARMA.php b/Business/Finance/Forecasting/ARMA.php index 69c6d0b5b..4dc5de738 100644 --- a/Business/Finance/Forecasting/ARMA.php +++ b/Business/Finance/Forecasting/ARMA.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; class ARMA diff --git a/Business/Finance/Forecasting/ClassicalDecomposition.php b/Business/Finance/Forecasting/ClassicalDecomposition.php index b45aaa8c9..ee7fa4f22 100644 --- a/Business/Finance/Forecasting/ClassicalDecomposition.php +++ b/Business/Finance/Forecasting/ClassicalDecomposition.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; diff --git a/Business/Finance/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php b/Business/Finance/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php index e44c60955..2aa496d13 100644 --- a/Business/Finance/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php +++ b/Business/Finance/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting\ExponentialSmoothing; @@ -35,7 +35,7 @@ class ExponentialSmoothing public function __construct(array $data) { - $this->data = $data; + $this->data = $data; } public function getRMSE() : float @@ -67,48 +67,48 @@ class ExponentialSmoothing { $this->rmse = PHP_INT_MAX; - if($trendType === TrendType::ALL || $seasonalType === SeasonalType::ALL) { + if ($trendType === TrendType::ALL || $seasonalType === SeasonalType::ALL) { $trends = [$trendType]; - if($trendType === TrendType::ALL) { + if ($trendType === TrendType::ALL) { $trends = [TrendType::NONE, TrendType::ADDITIVE, TrendType::MULTIPLICATIVE]; } $seasonals = [$seasonalType]; - if($seasonalType === SeasonalType::ALL) { + if ($seasonalType === SeasonalType::ALL) { $seasonals = [SeasonalType::NONE, SeasonalType::ADDITIVE, SeasonalType::MULTIPLICATIVE]; } $forecast = []; $bestError = PHP_INT_MAX; - foreach($trends as $trend) { - foreach($seasonals as $seasonal) { + foreach ($trends as $trend) { + foreach ($seasonals as $seasonal) { $tempForecast = $this->getForecast($future, $trend, $seasonal, $cycle, $damping); if ($this->rmse < $bestError) { $bestError = $this->rmse; - $forecast = $tempForecast; + $forecast = $tempForecast; } } } return $forecast; - } elseif($trendType === TrendType::NONE && $seasonalType === SeasonalType::NONE) { + } elseif ($trendType === TrendType::NONE && $seasonalType === SeasonalType::NONE) { return $this->getNoneNone($future); - } elseif($trendType === TrendType::NONE && $seasonalType === SeasonalType::ADDITIVE) { + } elseif ($trendType === TrendType::NONE && $seasonalType === SeasonalType::ADDITIVE) { return $this->getNoneAdditive($future, $cycle); - } elseif($trendType === TrendType::NONE && $seasonalType === SeasonalType::MULTIPLICATIVE) { + } elseif ($trendType === TrendType::NONE && $seasonalType === SeasonalType::MULTIPLICATIVE) { return $this->getNoneMultiplicative($future, $cycle); - } elseif($trendType === TrendType::ADDITIVE && $seasonalType === SeasonalType::NONE) { + } elseif ($trendType === TrendType::ADDITIVE && $seasonalType === SeasonalType::NONE) { return $this->getAdditiveNone($future, $damping); - } elseif($trendType === TrendType::ADDITIVE && $seasonalType === SeasonalType::ADDITIVE) { + } elseif ($trendType === TrendType::ADDITIVE && $seasonalType === SeasonalType::ADDITIVE) { return $this->getAdditiveAdditive($future, $cycle, $damping); - } elseif($trendType === TrendType::ADDITIVE && $seasonalType === SeasonalType::MULTIPLICATIVE) { + } elseif ($trendType === TrendType::ADDITIVE && $seasonalType === SeasonalType::MULTIPLICATIVE) { return $this->getAdditiveMultiplicative($future, $cycle, $damping); - } elseif($trendType === TrendType::MULTIPLICATIVE && $seasonalType === SeasonalType::NONE) { + } elseif ($trendType === TrendType::MULTIPLICATIVE && $seasonalType === SeasonalType::NONE) { return $this->getMultiplicativeNone($future, $damping); - } elseif($trendType === TrendType::MULTIPLICATIVE && $seasonalType === SeasonalType::ADDITIVE) { + } elseif ($trendType === TrendType::MULTIPLICATIVE && $seasonalType === SeasonalType::ADDITIVE) { return $this->getMultiplicativeAdditive($future, $cycle, $damping); - } elseif($trendType === TrendType::MULTIPLICATIVE && $seasonalType === SeasonalType::MULTIPLICATIVE) { + } elseif ($trendType === TrendType::MULTIPLICATIVE && $seasonalType === SeasonalType::MULTIPLICATIVE) { return $this->getMultiplicativeMultiplicative($future, $cycle, $damping); } @@ -117,12 +117,12 @@ class ExponentialSmoothing private function dampingSum(float $damping, int $length) : float { - if(abs($damping - 1) < 0.001) { + if (abs($damping - 1) < 0.001) { return $length; } $sum = 0; - for($i = 0; $i < $length; $i++) { + for ($i = 0; $i < $length; $i++) { $sum += pow($damping, $i); } @@ -137,14 +137,14 @@ class ExponentialSmoothing $alpha = 0.00; while ($alpha < 1) { - $error = []; + $error = []; $tempForecast = []; - for($i = 1; $i < $dataLength; $i++) { - $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) + (1 - $alpha) * $level[$i-1]; + for ($i = 1; $i < $dataLength; $i++) { + $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) + (1 - $alpha) * $level[$i - 1]; $tempForecast[$i] = $level[$i]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -172,27 +172,27 @@ class ExponentialSmoothing $forecast = []; $seasonal = []; - for($i = 1; $i < $cycle+1; $i++) { - $seasonal[$i] = $this->data[$i-1] - $level[0]; + for ($i = 1; $i < $cycle + 1; $i++) { + $seasonal[$i] = $this->data[$i - 1] - $level[0]; } $alpha = 0.00; while ($alpha < 1) { $gamma = 0.00; - while($gamma < 1) { + while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; - for($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + for ($i = 1; $i < $dataLength; $i++) { + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i-1]; - $seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $level[$i-1]) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i - 1]; + $seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $level[$i - 1]) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[$i] = $level[$i] + $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[$i] = $level[$i] + $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -223,7 +223,7 @@ class ExponentialSmoothing $forecast = []; $seasonal = []; - for($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $seasonal[$i] = $this->data[$i] / $level[0]; } @@ -231,19 +231,19 @@ class ExponentialSmoothing while ($alpha < 1) { $gamma = 0.00; - while($gamma < 1) { + while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; - for($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + for ($i = 1; $i < $dataLength; $i++) { + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i-1]; - $seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $level[$i-1]) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i - 1]; + $seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $level[$i - 1]) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[$i] = $level[$i] + $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[$i] = $level[$i] + $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -278,16 +278,16 @@ class ExponentialSmoothing while ($alpha < 1) { $beta = 0.00; - while($beta < 1) { - $error = []; + while ($beta < 1) { + $error = []; $tempForecast = []; - for($i = 1; $i < $dataLength; $i++) { - $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) + (1 - $alpha) * ($level[$i-1] + $damping * $trend[$i-1]); - $trend[$i] = $beta * ($level[$i] - $level[$i-1]) + (1 - $beta) * $damping * $trend[$i-1]; + for ($i = 1; $i < $dataLength; $i++) { + $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) + (1 - $alpha) * ($level[$i - 1] + $damping * $trend[$i - 1]); + $trend[$i] = $beta * ($level[$i] - $level[$i - 1]) + (1 - $beta) * $damping * $trend[$i - 1]; $tempForecast[$i] = $level[$i] + $this->dampingSum($damping, $i) * $trend[$i]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -320,37 +320,37 @@ class ExponentialSmoothing $seasonal = []; $sum = 0; - for($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $sum += ($this->data[$cycle] - $this->data[$i]) / $cycle; } $trend[0] *= $sum; - for($i = 1; $i < $cycle+1; $i++) { - $seasonal[$i] = $this->data[$i-1] - $level[0]; + for ($i = 1; $i < $cycle + 1; $i++) { + $seasonal[$i] = $this->data[$i - 1] - $level[0]; } $alpha = 0.00; while ($alpha < 1) { $beta = 0.00; - while($beta < 1) { + while ($beta < 1) { $gamma = 0.00; - while($gamma < 1) { + while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; - for($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + for ($i = 1; $i < $dataLength; $i++) { + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $seasonal[$i]) + (1 - $alpha) * ($level[$i-1] + $damping * $trend[$i-1]); - $trend[$i] = $beta * ($level[$i] - $level[$i-1]) + (1 - $beta) * $damping * $trend[$i-1]; - $seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $level[$i-1]) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $seasonal[$i]) + (1 - $alpha) * ($level[$i - 1] + $damping * $trend[$i - 1]); + $trend[$i] = $beta * ($level[$i] - $level[$i - 1]) + (1 - $beta) * $damping * $trend[$i - 1]; + $seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $level[$i - 1]) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[$i] = $level[$i] + $this->dampingSum($damping, $i) * $trend[$i] + $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[$i] = $level[$i] + $this->dampingSum($damping, $i) * $trend[$i] + $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -387,13 +387,13 @@ class ExponentialSmoothing $gamma_ = $gamma * (1 - $alpha); $sum = 0; - for($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $sum += ($this->data[$cycle] - $this->data[$i]) / $cycle; } $trend[0] *= $sum; - for($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $seasonal[$i] = $this->data[$i] / $level[0]; } @@ -401,23 +401,23 @@ class ExponentialSmoothing while ($alpha < 1) { $beta = 0.00; - while($beta < 1) { + while ($beta < 1) { $gamma = 0.00; - while($gamma < 1) { + while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; - for($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + for ($i = 1; $i < $dataLength; $i++) { + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $seasonal[$i]) + (1 - $alpha) * ($level[$i-1] + $damping * $trend[$i-1]); - $trend[$i] = $beta * ($level[$i] - $level[$i-1]) + (1 - $beta) * $damping * $trend[$i-1]; - $seasonal[$i+$cycle] = $gamma_*($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / ($level[$i-1] + $damping * $trend[$i-1]) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $seasonal[$i]) + (1 - $alpha) * ($level[$i - 1] + $damping * $trend[$i - 1]); + $trend[$i] = $beta * ($level[$i] - $level[$i - 1]) + (1 - $beta) * $damping * $trend[$i - 1]; + $seasonal[$i + $cycle] = $gamma_ * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / ($level[$i - 1] + $damping * $trend[$i - 1]) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[] = ($level[$i] + $this->dampingSum($damping, $i) * $trend[$i-1]) * $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[] = ($level[$i] + $this->dampingSum($damping, $i) * $trend[$i - 1]) * $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -455,16 +455,16 @@ class ExponentialSmoothing while ($alpha < 1) { $beta = 0.00; - while($beta < 1) { - $error = []; + while ($beta < 1) { + $error = []; $tempForecast = []; - for($i = 1; $i < $dataLength; $i++) { - $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) + (1 - $alpha) * $level[$i-1] * pow($trend[$i-1], $damping); - $trend[$i] = $beta * ($level[$i] / $level[$i-1]) + (1 - $beta) * pow($trend[$i-1], $damping); + for ($i = 1; $i < $dataLength; $i++) { + $level[$i] = $alpha * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) + (1 - $alpha) * $level[$i - 1] * pow($trend[$i - 1], $damping); + $trend[$i] = $beta * ($level[$i] / $level[$i - 1]) + (1 - $beta) * pow($trend[$i - 1], $damping); $tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)); - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -496,37 +496,37 @@ class ExponentialSmoothing $seasonal = []; $sum = 0; - for($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $sum += ($this->data[$cycle] - $this->data[$i]) / $cycle; } $trend[0] *= $sum; - for($i = 1; $i < $cycle+1; $i++) { - $seasonal[$i] = $this->data[$i-1] - $level[0]; + for ($i = 1; $i < $cycle + 1; $i++) { + $seasonal[$i] = $this->data[$i - 1] - $level[0]; } $alpha = 0.00; while ($alpha < 1) { $beta = 0.00; - while($beta < 1) { + while ($beta < 1) { $gamma = 0.00; - while($gamma < 1) { + while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; - for($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + for ($i = 1; $i < $dataLength; $i++) { + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i-1] * pow($trend[$i-1], $damping); - $trend[$i] = $beta * ($level[$i] / $level[$i-1]) + (1 - $beta) * pow($trend[$i-1], $damping); - $seasonal[$i+$cycle] = $gamma_*(($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) - $level[$i-1] * pow($trend[$i-1], $damping)) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $seasonal[$i]) + (1 - $alpha) * $level[$i - 1] * pow($trend[$i - 1], $damping); + $trend[$i] = $beta * ($level[$i] / $level[$i - 1]) + (1 - $beta) * pow($trend[$i - 1], $damping); + $seasonal[$i + $cycle] = $gamma_ * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) - $level[$i - 1] * pow($trend[$i - 1], $damping)) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) + $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) + $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); @@ -562,13 +562,13 @@ class ExponentialSmoothing $seasonal = []; $sum = 0; - for($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $sum += ($this->data[$cycle] - $this->data[$i]) / $cycle; } $trend[0] *= $sum; - for($i = 1; $i < $cycle+1; $i++) { + for ($i = 1; $i < $cycle + 1; $i++) { $seasonal[$i] = $this->data[$i] / $level[0]; } @@ -576,23 +576,23 @@ class ExponentialSmoothing while ($alpha < 1) { $beta = 0.00; - while($beta < 1) { + while ($beta < 1) { $gamma = 0.00; - while($gamma < 1) { + while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); - $error = []; + $error = []; $tempForecast = []; - for($i = 1; $i < $dataLength; $i++) { - $hm = (int) floor(($i-1) % $cycle) + 1; + for ($i = 1; $i < $dataLength; $i++) { + $hm = (int) floor(($i - 1) % $cycle) + 1; - $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i-1] * pow($trend[$i-1], $damping); - $trend[$i] = $beta * ($level[$i] / $level[$i-1]) + (1 - $beta) * pow($trend[$i-1], $damping); - $seasonal[$i+$cycle] = $gamma_*($i < $dataLength - $future ? $this->data[$i-1] : $tempForecast[$i-1]) / ($level[$i-1] * pow($trend[$i-1], $damping)) + (1 - $gamma_) * $seasonal[$i]; + $level[$i] = $alpha * (($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / $seasonal[$i]) + (1 - $alpha) * $level[$i - 1] * pow($trend[$i - 1], $damping); + $trend[$i] = $beta * ($level[$i] / $level[$i - 1]) + (1 - $beta) * pow($trend[$i - 1], $damping); + $seasonal[$i + $cycle] = $gamma_ * ($i < $dataLength - $future ? $this->data[$i - 1] : $tempForecast[$i - 1]) / ($level[$i - 1] * pow($trend[$i - 1], $damping)) + (1 - $gamma_) * $seasonal[$i]; - $tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) * $seasonal[$i+$hm]; - $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; + $tempForecast[$i] = $level[$i] * pow($trend[$i], $this->dampingSum($damping, $i)) * $seasonal[$i + $hm]; + $error[] = $i < $dataLength - $future ? $this->data[$i] - $tempForecast[$i] : 0; } $tempRMSE = Error::getRootMeanSquaredError($error); diff --git a/Business/Finance/Forecasting/ExponentialSmoothing/SeasonalType.php b/Business/Finance/Forecasting/ExponentialSmoothing/SeasonalType.php index 22c8bd549..d26550a7e 100644 --- a/Business/Finance/Forecasting/ExponentialSmoothing/SeasonalType.php +++ b/Business/Finance/Forecasting/ExponentialSmoothing/SeasonalType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting\ExponentialSmoothing; diff --git a/Business/Finance/Forecasting/ExponentialSmoothing/TrendType.php b/Business/Finance/Forecasting/ExponentialSmoothing/TrendType.php index 72413e498..91348fd2c 100644 --- a/Business/Finance/Forecasting/ExponentialSmoothing/TrendType.php +++ b/Business/Finance/Forecasting/ExponentialSmoothing/TrendType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting\ExponentialSmoothing; diff --git a/Business/Finance/Forecasting/GARCH.php b/Business/Finance/Forecasting/GARCH.php index 07a3654b0..1226e4c42 100644 --- a/Business/Finance/Forecasting/GARCH.php +++ b/Business/Finance/Forecasting/GARCH.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; class GARCH diff --git a/Business/Finance/Forecasting/MA.php b/Business/Finance/Forecasting/MA.php index 4ec6a3103..dcf92b3f4 100644 --- a/Business/Finance/Forecasting/MA.php +++ b/Business/Finance/Forecasting/MA.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; class MA diff --git a/Business/Finance/Forecasting/NAR.php b/Business/Finance/Forecasting/NAR.php index 7f499cfa7..1e9523a8b 100644 --- a/Business/Finance/Forecasting/NAR.php +++ b/Business/Finance/Forecasting/NAR.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; class NAR diff --git a/Business/Finance/Forecasting/NMA.php b/Business/Finance/Forecasting/NMA.php index c8a67b716..5ede809e7 100644 --- a/Business/Finance/Forecasting/NMA.php +++ b/Business/Finance/Forecasting/NMA.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; class NMA diff --git a/Business/Finance/Forecasting/SARIMA.php b/Business/Finance/Forecasting/SARIMA.php index 53573e3c3..d179e6fb5 100644 --- a/Business/Finance/Forecasting/SARIMA.php +++ b/Business/Finance/Forecasting/SARIMA.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; class SARIMA diff --git a/Business/Finance/Forecasting/SmoothingType.php b/Business/Finance/Forecasting/SmoothingType.php index d14f75f2d..f79b10f57 100644 --- a/Business/Finance/Forecasting/SmoothingType.php +++ b/Business/Finance/Forecasting/SmoothingType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance\Forecasting; diff --git a/Business/Finance/Loan.php b/Business/Finance/Loan.php index 2938a44c5..45533801f 100644 --- a/Business/Finance/Loan.php +++ b/Business/Finance/Loan.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance; diff --git a/Business/Finance/Lorenzkurve.php b/Business/Finance/Lorenzkurve.php index fb1b15a56..9042e7f2d 100644 --- a/Business/Finance/Lorenzkurve.php +++ b/Business/Finance/Lorenzkurve.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance; diff --git a/Business/Finance/StockBonds.php b/Business/Finance/StockBonds.php index cae66824c..d4f8ec313 100644 --- a/Business/Finance/StockBonds.php +++ b/Business/Finance/StockBonds.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Finance; diff --git a/Business/Marketing/Metrics.php b/Business/Marketing/Metrics.php index 7a0124756..670aa4fbd 100644 --- a/Business/Marketing/Metrics.php +++ b/Business/Marketing/Metrics.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Marketing; diff --git a/Business/Marketing/NetPromoterScore.php b/Business/Marketing/NetPromoterScore.php index 0c22eee8d..4f8882567 100644 --- a/Business/Marketing/NetPromoterScore.php +++ b/Business/Marketing/NetPromoterScore.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Marketing; @@ -72,10 +72,10 @@ class NetPromoterScore { $passives = 0; $detractors = 0; - foreach($this->scores as $score) { - if($score > 8) { + foreach ($this->scores as $score) { + if ($score > 8) { $promoters++; - } elseif($score > 6) { + } elseif ($score > 6) { $passives++; } else { $detractors++; @@ -99,8 +99,8 @@ class NetPromoterScore { public function countDetractors() : int { $count = 0; - foreach($this->scores as $score) { - if($score < 7) { + foreach ($this->scores as $score) { + if ($score < 7) { $count++; } } @@ -120,8 +120,8 @@ class NetPromoterScore { public function countPassives() : int { $count = 0; - foreach($this->scores as $score) { - if($score > 6 && $score < 9) { + foreach ($this->scores as $score) { + if ($score > 6 && $score < 9) { $count++; } } @@ -141,8 +141,8 @@ class NetPromoterScore { public function countPromoters() : int { $count = 0; - foreach($this->scores as $score) { - if($score > 8) { + foreach ($this->scores as $score) { + if ($score > 8) { $count++; } } diff --git a/Business/Programming/Metrics.php b/Business/Programming/Metrics.php index 04b1056ad..d1287ad90 100644 --- a/Business/Programming/Metrics.php +++ b/Business/Programming/Metrics.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Programming; @@ -42,17 +42,16 @@ class Metrics { */ public static function abcScore(int $a, int $b, int $c) : int { - return (int) sqrt($a*$a+$b*$b+$c*$c); + return (int) sqrt($a * $a + $b * $b + $c * $c); } /** * Calculate the C.R.A.P score * - * @latex r = \sqrt{a^{2} + b^{2} + c^{2}} + * @latex r = com^{2} \times (1 - cov)^{3} + com * - * @param int $a Assignments - * @param int $b Branches - * @param int $c Conditionals + * @param int $complexity Complexity + * @param int $coverage Coverage * * @return int * diff --git a/Business/Sales/MarketShareEstimation.php b/Business/Sales/MarketShareEstimation.php index b2b03079a..0a6d525bd 100644 --- a/Business/Sales/MarketShareEstimation.php +++ b/Business/Sales/MarketShareEstimation.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Business\Sales; @@ -44,8 +44,8 @@ class MarketShareEstimation { public static function getRankFromMarketShare(int $participants, float $marketShare, float $modifier = 1.0) : int { $sum = 0.0; - for($i = 0; $i < $participants; $i++) { - $sum += 1 / pow($i+1, $modifier); + for ($i = 0; $i < $participants; $i++) { + $sum += 1 / pow($i + 1, $modifier); } return (int) round(pow(1 / ($marketShare * $sum), 1 / $modifier)); @@ -67,8 +67,8 @@ class MarketShareEstimation { public static function getMarketShareFromRank(int $participants, int $rank, float $modifier = 1.0) : float { $sum = 0.0; - for($i = 0; $i < $participants; $i++) { - $sum += 1 / pow($i+1, $modifier); + for ($i = 0; $i < $participants; $i++) { + $sum += 1 / pow($i + 1, $modifier); } return (1 / pow($rank, $modifier)) / $sum; diff --git a/Config/OptionsInterface.php b/Config/OptionsInterface.php index 67ad30553..2a48ecad9 100644 --- a/Config/OptionsInterface.php +++ b/Config/OptionsInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Config; diff --git a/Config/OptionsTrait.php b/Config/OptionsTrait.php index 1bf3b2d5c..6b358548d 100644 --- a/Config/OptionsTrait.php +++ b/Config/OptionsTrait.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Config; diff --git a/Config/SettingsAbstract.php b/Config/SettingsAbstract.php index aa65eb9ca..f371de13a 100644 --- a/Config/SettingsAbstract.php +++ b/Config/SettingsAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Config; diff --git a/Console/CommandManager.php b/Console/CommandManager.php index f15e8d25f..b9c54dc49 100644 --- a/Console/CommandManager.php +++ b/Console/CommandManager.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Console; diff --git a/Contract/ArrayableInterface.php b/Contract/ArrayableInterface.php index cd978587d..b03b31ba7 100644 --- a/Contract/ArrayableInterface.php +++ b/Contract/ArrayableInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Contract; diff --git a/Contract/RenderableInterface.php b/Contract/RenderableInterface.php index dcb9917e6..1d0090f00 100644 --- a/Contract/RenderableInterface.php +++ b/Contract/RenderableInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Contract; diff --git a/DataStorage/Cache/CacheFactory.php b/DataStorage/Cache/CacheFactory.php index daa5ef4c4..5507bda80 100644 --- a/DataStorage/Cache/CacheFactory.php +++ b/DataStorage/Cache/CacheFactory.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Cache; diff --git a/DataStorage/Cache/CacheInterface.php b/DataStorage/Cache/CacheInterface.php index 015c56123..c6ae99051 100644 --- a/DataStorage/Cache/CacheInterface.php +++ b/DataStorage/Cache/CacheInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Cache; use phpOMS\Stdlib\Base\Exception\InvalidEnumValue; diff --git a/DataStorage/Cache/CachePool.php b/DataStorage/Cache/CachePool.php index eef56b141..5d897487c 100644 --- a/DataStorage/Cache/CachePool.php +++ b/DataStorage/Cache/CachePool.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Cache; @@ -39,7 +39,7 @@ class CachePool implements OptionsInterface /** * MemCache instance. * - * @var \phpOMS\DataStorage\Cache\CacheInterface + * @var \phpOMS\DataStorage\Cache\CacheInterface[] * @since 1.0.0 */ private $pool = null; @@ -106,11 +106,11 @@ class CachePool implements OptionsInterface */ public function get(string $key = '') /* : ?CacheInterface */ { - if((!empty($key) && !isset($this->pool[$key])) || empty($this->pool)) { + if ((!empty($key) && !isset($this->pool[$key])) || empty($this->pool)) { return null; } - if(empty($key)) { + if (empty($key)) { return reset($this->pool); } diff --git a/DataStorage/Cache/CacheStatus.php b/DataStorage/Cache/CacheStatus.php index ffb58806c..d30660457 100644 --- a/DataStorage/Cache/CacheStatus.php +++ b/DataStorage/Cache/CacheStatus.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Cache; diff --git a/DataStorage/Cache/CacheType.php b/DataStorage/Cache/CacheType.php index 35b12ac41..a4e331ea9 100644 --- a/DataStorage/Cache/CacheType.php +++ b/DataStorage/Cache/CacheType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Cache; diff --git a/DataStorage/Cache/FileCache.php b/DataStorage/Cache/FileCache.php index 236e882ea..df4f5a264 100644 --- a/DataStorage/Cache/FileCache.php +++ b/DataStorage/Cache/FileCache.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Cache; @@ -108,7 +108,7 @@ class FileCache implements CacheInterface */ public function setStatus(int $status) /* : void */ { - if(!CacheStatus::isValidValue($status)) { + if (!CacheStatus::isValidValue($status)) { throw new InvalidEnumValue($status); } @@ -142,7 +142,7 @@ class FileCache implements CacheInterface */ public function set($key, $value, int $expire = -1) /* : void */ { - if($this->status !== CacheStatus::ACTIVE) { + if ($this->status !== CacheStatus::ACTIVE) { return false; } @@ -159,7 +159,7 @@ class FileCache implements CacheInterface */ public function add($key, $value, int $expire = -1) : bool { - if($this->status !== CacheStatus::ACTIVE) { + if ($this->status !== CacheStatus::ACTIVE) { return false; } @@ -262,9 +262,9 @@ class FileCache implements CacheInterface private function getExpire(string $raw) : int { $expireStart = strpos($raw, self::DELIM); - $expireEnd = strpos($raw, self::DELIM, $expireStart+1); + $expireEnd = strpos($raw, self::DELIM, $expireStart + 1); - return (int) substr($raw, $expireStart+1, $expireEnd - ($expireStart+1)); + return (int) substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1)); } /** @@ -272,14 +272,14 @@ class FileCache implements CacheInterface */ public function get($key, int $expire = -1) { - if($this->status !== CacheStatus::ACTIVE) { + if ($this->status !== CacheStatus::ACTIVE) { return null; } $name = File::sanitize($key, self::SANITIZE); $path = $this->cachePath . '/' . trim($name, '/') . '.cache'; - if(!File::exists($path)) { + if (!File::exists($path)) { return null; } @@ -294,8 +294,8 @@ class FileCache implements CacheInterface $type = $raw[0]; $expireStart = strpos($raw, self::DELIM); - $expireEnd = strpos($raw, self::DELIM, $expireStart+1); - $cacheExpire = substr($raw, $expireStart+1, $expireEnd - ($expireStart+1)); + $expireEnd = strpos($raw, self::DELIM, $expireStart + 1); + $cacheExpire = substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1)); if ($cacheExpire >= 0 && $created + $cacheExpire < $now) { $this->delete($key); @@ -324,7 +324,7 @@ class FileCache implements CacheInterface case CacheType::_SERIALIZABLE: case CacheType::_JSONSERIALIZABLE: $namespaceStart = strpos($raw, self::DELIM, $expireEnd); - $namespaceEnd = strpos($raw, self::DELIM, $namespaceStart+1); + $namespaceEnd = strpos($raw, self::DELIM, $namespaceStart + 1); $namespace = substr($raw, $namespaceStart, $namespaceEnd); $value = $namespace::unserialize(substr($raw, $namespaceEnd + 1)); @@ -339,7 +339,7 @@ class FileCache implements CacheInterface */ public function delete($key, int $expire = -1) : bool { - if($this->status !== CacheStatus::ACTIVE) { + if ($this->status !== CacheStatus::ACTIVE) { return false; } @@ -357,8 +357,8 @@ class FileCache implements CacheInterface $now = time(); $raw = file_get_contents($path); $expireStart = strpos($raw, self::DELIM); - $expireEnd = strpos($raw, self::DELIM, $expireStart+1); - $cacheExpire = substr($raw, $expireStart+1, $expireEnd - ($expireStart+1)); + $expireEnd = strpos($raw, self::DELIM, $expireStart + 1); + $cacheExpire = substr($raw, $expireStart + 1, $expireEnd - ($expireStart + 1)); if ($cacheExpire >= 0 && $created + $cacheExpire > $now) { File::delete($path); @@ -402,7 +402,7 @@ class FileCache implements CacheInterface */ public function replace($key, $value, int $expire = -1) : bool { - if($this->status !== CacheStatus::ACTIVE) { + if ($this->status !== CacheStatus::ACTIVE) { return false; } diff --git a/DataStorage/Cache/MemCache.php b/DataStorage/Cache/MemCache.php index 4314263af..0d8906823 100644 --- a/DataStorage/Cache/MemCache.php +++ b/DataStorage/Cache/MemCache.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Cache; @@ -50,7 +50,7 @@ class MemCache implements CacheInterface */ public function __construct() { - $this->memc = new self(); + $this->memc = null; } /** diff --git a/DataStorage/Cache/MemCached.php b/DataStorage/Cache/MemCached.php new file mode 100644 index 000000000..76814a13a --- /dev/null +++ b/DataStorage/Cache/MemCached.php @@ -0,0 +1,178 @@ +memc = null; + } + + /** + * Adding server to server pool. + * + * @param mixed $data Server data array + * + * @return void + * + * @since 1.0.0 + */ + public function addServer($data) + { + $this->memc->addServer($data['host'], $data['port'], $data['timeout']); + } + + /** + * {@inheritdoc} + */ + public function set($key, $value, int $expire = -1) /* : void */ + { + $this->memc->set($key, $value, false, $expire); + } + + /** + * {@inheritdoc} + */ + public function add($key, $value, int $expire = -1) : bool + { + return $this->memc->add($key, $value, false, $expire); + } + + /** + * {@inheritdoc} + */ + public function get($key, int $expire = -1) + { + return $this->memc->get($key); + } + + /** + * {@inheritdoc} + */ + public function delete($key, int $expire = -1) : bool + { + $this->memc->delete($key); + } + + /** + * {@inheritdoc} + */ + public function flush(int $expire = 0) : bool + { + $this->memc->flush(); + + return true; + } + + /** + * {@inheritdoc} + */ + public function flushAll() : bool + { + $this->memc->flush(); + + return true; + } + + /** + * {@inheritdoc} + */ + public function replace($key, $value, int $expire = -1) : bool + { + $this->memc->replace($key, $value, false, $expire); + } + + /** + * {@inheritdoc} + */ + public function stats() : array + { + /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */ + return $this->memc->getExtendedStats(); + } + + /** + * {@inheritdoc} + */ + public function getThreshold() : int + { + return $this->threshold; + } + + /** + * {@inheritdoc} + */ + public function setStatus(int $status) /* : void */ + { + $this->status = $status; + } + + /** + * Destructor. + * + * @since 1.0.0 + */ + public function __destruct() + { + $this->close(); + } + + /** + * Closing cache. + * + * @since 1.0.0 + */ + public function close() + { + if ($this->memc !== null) { + $this->memc->close(); + $this->memc = null; + } + } + +} diff --git a/DataStorage/Cache/NullCache.php b/DataStorage/Cache/NullCache.php index 95b3a07e6..92dbd3e2f 100644 --- a/DataStorage/Cache/NullCache.php +++ b/DataStorage/Cache/NullCache.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Cache; diff --git a/DataStorage/Cache/RedisCache.php b/DataStorage/Cache/RedisCache.php index 586ec294e..27f9a5863 100644 --- a/DataStorage/Cache/RedisCache.php +++ b/DataStorage/Cache/RedisCache.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Cache; diff --git a/DataStorage/Cache/WinCache.php b/DataStorage/Cache/WinCache.php index cab734a1c..0506bb8c2 100644 --- a/DataStorage/Cache/WinCache.php +++ b/DataStorage/Cache/WinCache.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Cache; diff --git a/DataStorage/Cookie/CookieJar.php b/DataStorage/Cookie/CookieJar.php index 2124a8d4f..8ca3532a6 100644 --- a/DataStorage/Cookie/CookieJar.php +++ b/DataStorage/Cookie/CookieJar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Cookie; @@ -122,12 +122,12 @@ class CookieJar */ public function delete(string $id) : bool { - if($this->remove($id)) { + if ($this->remove($id)) { if (self::$isLocked) { throw new LockException('CookieJar'); } - if(!headers_sent()) { + if (!headers_sent()) { setcookie($id, '', time() - 3600); return true; diff --git a/DataStorage/DataMapperInterface.php b/DataStorage/DataMapperInterface.php index 48aaf4925..363b6048b 100644 --- a/DataStorage/DataMapperInterface.php +++ b/DataStorage/DataMapperInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage; diff --git a/DataStorage/Database/BuilderAbstract.php b/DataStorage/Database/BuilderAbstract.php index 87a8702bb..6add0d8e1 100644 --- a/DataStorage/Database/BuilderAbstract.php +++ b/DataStorage/Database/BuilderAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database; diff --git a/DataStorage/Database/Connection/ConnectionAbstract.php b/DataStorage/Database/Connection/ConnectionAbstract.php index 20f4379a7..1dfec1ff2 100644 --- a/DataStorage/Database/Connection/ConnectionAbstract.php +++ b/DataStorage/Database/Connection/ConnectionAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Connection; @@ -65,15 +65,15 @@ abstract class ConnectionAbstract implements ConnectionInterface /** * Database type. * - * @var \phpOMS\DataStorage\Database\DatabaseType + * @var string * @since 1.0.0 */ - protected $type = null; + protected $type = 'undefined'; /** * Database status. * - * @var DatabaseStatus + * @var int * @since 1.0.0 */ protected $status = DatabaseStatus::CLOSED; @@ -89,7 +89,7 @@ abstract class ConnectionAbstract implements ConnectionInterface /** * Database grammar. * - * @var Grammar + * @var SchemaGrammar * @since 1.0.0 */ protected $schemaGrammar = null; diff --git a/DataStorage/Database/Connection/ConnectionFactory.php b/DataStorage/Database/Connection/ConnectionFactory.php index 9448235bd..53856bb09 100644 --- a/DataStorage/Database/Connection/ConnectionFactory.php +++ b/DataStorage/Database/Connection/ConnectionFactory.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Connection; diff --git a/DataStorage/Database/Connection/ConnectionInterface.php b/DataStorage/Database/Connection/ConnectionInterface.php index cd320bf30..e19175ab6 100644 --- a/DataStorage/Database/Connection/ConnectionInterface.php +++ b/DataStorage/Database/Connection/ConnectionInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Connection; diff --git a/DataStorage/Database/Connection/MysqlConnection.php b/DataStorage/Database/Connection/MysqlConnection.php index ad739724b..ec1f23cd7 100644 --- a/DataStorage/Database/Connection/MysqlConnection.php +++ b/DataStorage/Database/Connection/MysqlConnection.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Connection; @@ -60,32 +60,11 @@ class MysqlConnection extends ConnectionAbstract { $this->dbdata = isset($dbdata) ? $dbdata : $this->dbdata; - if(!isset($this->dbdata['db'])) { - throw new InvalidConnectionConfigException('db'); - } - - if(!isset($this->dbdata['host'])) { - throw new InvalidConnectionConfigException('host'); - } - - if(!isset($this->dbdata['port'])) { - throw new InvalidConnectionConfigException('port'); - } - - if(!isset($this->dbdata['database'])) { - throw new InvalidConnectionConfigException('database'); - } - - if(!isset($this->dbdata['login'])) { - throw new InvalidConnectionConfigException('login'); - } - - if(!isset($this->dbdata['password'])) { - throw new InvalidConnectionConfigException('password'); + if (!isset($this->dbdata['db'], $this->dbdata['host'], $this->dbdata['port'], $this->dbdata['database'], $this->dbdata['login'], $this->dbdata['password'])) { + throw new InvalidConnectionConfigException(json_encode($this->dbdata)); } $this->close(); - $this->prefix = $dbdata['prefix'] ?? ''; try { diff --git a/DataStorage/Database/Connection/PostgresConnection.php b/DataStorage/Database/Connection/PostgresConnection.php index 60545b66f..6a076e32b 100644 --- a/DataStorage/Database/Connection/PostgresConnection.php +++ b/DataStorage/Database/Connection/PostgresConnection.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Connection; diff --git a/DataStorage/Database/Connection/SQLiteConnection.php b/DataStorage/Database/Connection/SQLiteConnection.php index 007ef2b6d..a22faad13 100644 --- a/DataStorage/Database/Connection/SQLiteConnection.php +++ b/DataStorage/Database/Connection/SQLiteConnection.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Connection; diff --git a/DataStorage/Database/Connection/SqlServerConnection.php b/DataStorage/Database/Connection/SqlServerConnection.php index 00bd23b30..1a49f0882 100644 --- a/DataStorage/Database/Connection/SqlServerConnection.php +++ b/DataStorage/Database/Connection/SqlServerConnection.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Connection; diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 8c7e7abd6..b31884969 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database; @@ -149,7 +149,7 @@ class DataMapperAbstract implements DataMapperInterface /** * Highest mapper to know when to clear initialized objects * - * @var DataMapperAbstract + * @var string * @since 1.0.0 */ protected static $parentMapper = null; @@ -269,8 +269,6 @@ class DataMapperAbstract implements DataMapperInterface // todo: how to handle with of parent objects/extends/relations self::$fields = $objects; - - //return __CLASS__; } /** @@ -304,7 +302,7 @@ class DataMapperAbstract implements DataMapperInterface ]; // clear parent and objects - if(static::class === self::$parentMapper) { + if (static::class === self::$parentMapper) { self::$initObjects = []; self::$parentMapper = null; } @@ -325,8 +323,8 @@ class DataMapperAbstract implements DataMapperInterface $query = static::getQuery(); - foreach(static::$columns as $col) { - if(isset($col['autocomplete']) && $col['autocomplete']) { + foreach (static::$columns as $col) { + if (isset($col['autocomplete']) && $col['autocomplete']) { $query->where(static::$table . '.' . $col['name'], 'LIKE', '%' . $search . '%', 'OR'); } } @@ -348,7 +346,7 @@ class DataMapperAbstract implements DataMapperInterface { self::extend(__CLASS__); - if($obj === null || + if ($obj === null || (is_object($obj) && strpos($className = get_class($obj), '\Null') !== false) ) { return null; @@ -379,7 +377,7 @@ class DataMapperAbstract implements DataMapperInterface { self::extend(__CLASS__); - $objId = self::createModelArray($obj); + $objId = self::createModelArray($obj); settype($objId, static::$columns[static::$primaryField]['type']); $obj[static::$columns[static::$primaryField]['internal']] = $objId; @@ -507,7 +505,7 @@ class DataMapperAbstract implements DataMapperInterface */ private static function getObjectId($obj, \ReflectionClass $reflectionClass = null) { - $reflectionClass = $reflectionClass ?? new \ReflectionClass(get_class($obj)); + $reflectionClass = $reflectionClass ?? new \ReflectionClass($obj); $reflectionProperty = $reflectionClass->getProperty(static::$columns[static::$primaryField]['internal']); if (!($isPublic = $reflectionProperty->isPublic())) { @@ -596,7 +594,7 @@ class DataMapperAbstract implements DataMapperInterface } if (!isset($relReflectionClass)) { - $relReflectionClass = new \ReflectionClass(get_class($value)); + $relReflectionClass = new \ReflectionClass($value); } $primaryKey = $mapper::getObjectId($value, $relReflectionClass); @@ -931,7 +929,7 @@ class DataMapperAbstract implements DataMapperInterface } if (!isset($relReflectionClass)) { - $relReflectionClass = new \ReflectionClass(get_class($value)); + $relReflectionClass = new \ReflectionClass($value); } $primaryKey = $mapper::getObjectId($value, $relReflectionClass); @@ -992,11 +990,11 @@ class DataMapperAbstract implements DataMapperInterface $removes = array_diff($many[$propertyName], array_keys($objsIds[$propertyName] ?? [])); $adds = array_diff(array_keys($objsIds[$propertyName] ?? []), $many[$propertyName]); - if(!empty($removes)) { + if (!empty($removes)) { self::deleteRelationTable($propertyName, $removes, $objId); } - if(!empty($adds)) { + if (!empty($adds)) { self::createRelationTable($propertyName, $adds, $objId); } } @@ -1162,11 +1160,11 @@ class DataMapperAbstract implements DataMapperInterface { self::extend(__CLASS__); - $reflectionClass = new \ReflectionClass(get_class($obj)); + $reflectionClass = new \ReflectionClass($obj); $objId = self::getObjectId($obj, $reflectionClass); $update = true; - if(empty($objId)) { + if (empty($objId)) { $update = false; self::create($obj, $relations); } @@ -1175,7 +1173,7 @@ class DataMapperAbstract implements DataMapperInterface self::updateHasMany($reflectionClass, $obj, $objId); } - if($update) { + if ($update) { self::updateModel($obj, $objId, $reflectionClass); } @@ -1229,14 +1227,14 @@ class DataMapperAbstract implements DataMapperInterface } if (!isset($relReflectionClass)) { - $relReflectionClass = new \ReflectionClass(get_class($value)); + $relReflectionClass = new \ReflectionClass($value); } $primaryKey = $mapper::getObjectId($value, $relReflectionClass); // already in db if (!empty($primaryKey)) { - if($relations === RelationType::ALL) { + if ($relations === RelationType::ALL) { $objsIds[$key] = $mapper::delete($value); } else { $objsIds[$key] = $primaryKey; @@ -1324,7 +1322,7 @@ class DataMapperAbstract implements DataMapperInterface $properties = $reflectionClass->getProperties(); - if($relations === RelationType::ALL) { + if ($relations === RelationType::ALL) { foreach ($properties as $property) { $propertyName = $property->getName(); @@ -1372,10 +1370,10 @@ class DataMapperAbstract implements DataMapperInterface { self::extend(__CLASS__); - $reflectionClass = new \ReflectionClass(get_class($obj)); + $reflectionClass = new \ReflectionClass($obj); $objId = self::getObjectId($obj, $reflectionClass); - if(empty($objId)) { + if (empty($objId)) { return null; } @@ -1478,7 +1476,7 @@ class DataMapperAbstract implements DataMapperInterface public static function populateManyToMany(array $result, &$obj) /* : void */ { // todo: maybe pass reflectionClass as optional parameter for performance increase - $reflectionClass = new \ReflectionClass(get_class($obj)); + $reflectionClass = new \ReflectionClass($obj); foreach ($result as $member => $values) { if (!empty($values) && $reflectionClass->hasProperty($member)) { @@ -1487,7 +1485,7 @@ class DataMapperAbstract implements DataMapperInterface $reflectionProperty = $reflectionClass->getProperty($member); $values = array_diff($values, array_keys(self::$initObjects[$mapper] ?? [])); - if(empty($values)) { + if (empty($values)) { continue; } @@ -1523,7 +1521,7 @@ class DataMapperAbstract implements DataMapperInterface $mapper = static::$hasMany[$member]['mapper']; $values = array_diff($values, array_keys(self::$initObjects[$mapper] ?? [])); - if(empty($values)) { + if (empty($values)) { continue; } @@ -1546,7 +1544,7 @@ class DataMapperAbstract implements DataMapperInterface */ public static function populateHasOne(&$obj) /* : void */ { - $reflectionClass = new \ReflectionClass(get_class($obj)); + $reflectionClass = new \ReflectionClass($obj); foreach (static::$hasOne as $member => $one) { // todo: is that if necessary? performance is suffering for sure! @@ -1560,7 +1558,7 @@ class DataMapperAbstract implements DataMapperInterface /** @var string $mapper */ $mapper = static::$hasOne[$member]['mapper']; - if(self::isInitialized($mapper, ($id = $reflectionProperty->getValue($obj)))) { + if (self::isInitialized($mapper, ($id = $reflectionProperty->getValue($obj)))) { $value = self::$initObjects[$mapper][$id]; } else { $value = $mapper::get($reflectionProperty->getValue($obj)); @@ -1592,7 +1590,7 @@ class DataMapperAbstract implements DataMapperInterface /** @var string $mapper */ $mapper = static::$hasOne[$member]['mapper']; - if(self::isInitialized($mapper, $obj['member'])) { + if (self::isInitialized($mapper, $obj['member'])) { $value = self::$initObjects[$mapper][$obj['member']]; } else { $value = $mapper::getArray($obj[$member]); @@ -1615,7 +1613,7 @@ class DataMapperAbstract implements DataMapperInterface */ public static function populateOwnsOne(&$obj) /* : void */ { - $reflectionClass = new \ReflectionClass(get_class($obj)); + $reflectionClass = new \ReflectionClass($obj); foreach (static::$ownsOne as $member => $one) { // todo: is that if necessary? performance is suffering for sure! @@ -1629,7 +1627,7 @@ class DataMapperAbstract implements DataMapperInterface /** @var string $mapper */ $mapper = static::$ownsOne[$member]['mapper']; - if(self::isInitialized($mapper, ($id = $reflectionProperty->getValue($obj)))) { + if (self::isInitialized($mapper, ($id = $reflectionProperty->getValue($obj)))) { $value = self::$initObjects[$mapper][$id]; } else { $value = $mapper::get($reflectionProperty->getValue($obj)); @@ -1661,7 +1659,7 @@ class DataMapperAbstract implements DataMapperInterface /** @var string $mapper */ $mapper = static::$ownsOne[$member]['mapper']; - if(self::isInitialized($mapper, $obj[$member])) { + if (self::isInitialized($mapper, $obj[$member])) { $value = self::$initObjects[$mapper][$obj[$member]]; } else { $value = $mapper::getArray($obj[$member]); @@ -1684,7 +1682,7 @@ class DataMapperAbstract implements DataMapperInterface */ public static function populateBelongsTo(&$obj) /* : void */ { - $reflectionClass = new \ReflectionClass(get_class($obj)); + $reflectionClass = new \ReflectionClass($obj); foreach (static::$belongsTo as $member => $one) { // todo: is that if necessary? performance is suffering for sure! @@ -1698,7 +1696,7 @@ class DataMapperAbstract implements DataMapperInterface /** @var string $mapper */ $mapper = static::$belongsTo[$member]['mapper']; - if(self::isInitialized($mapper, ($id = $reflectionProperty->getValue($obj)))) { + if (self::isInitialized($mapper, ($id = $reflectionProperty->getValue($obj)))) { $value = self::$initObjects[$mapper][$id]; } else { $value = $mapper::get($reflectionProperty->getValue($obj)); @@ -1730,7 +1728,7 @@ class DataMapperAbstract implements DataMapperInterface /** @var string $mapper */ $mapper = static::$belongsTo[$member]['mapper']; - if(self::isInitialized($mapper, $obj[$member])) { + if (self::isInitialized($mapper, $obj[$member])) { $value = self::$initObjects[$mapper][$obj[$member]]; } else { $value = $mapper::get($obj[$member]); @@ -1754,7 +1752,7 @@ class DataMapperAbstract implements DataMapperInterface */ public static function populateAbstract(array $result, $obj) { - $reflectionClass = new \ReflectionClass(get_class($obj)); + $reflectionClass = new \ReflectionClass($obj); foreach ($result as $column => $value) { if (isset(static::$columns[$column]['internal']) /* && $reflectionClass->hasProperty(static::$columns[$column]['internal']) */) { @@ -1765,7 +1763,7 @@ class DataMapperAbstract implements DataMapperInterface } if (in_array(static::$columns[$column]['type'], ['string', 'int', 'float', 'bool'])) { - if($value !== null || $reflectionProperty->getValue($obj) !== null) { + if ($value !== null || $reflectionProperty->getValue($obj) !== null) { settype($value, static::$columns[$column]['type']); } @@ -1838,7 +1836,7 @@ class DataMapperAbstract implements DataMapperInterface */ public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null) { - if(!isset(self::$parentMapper)) { + if (!isset(self::$parentMapper)) { self::setUpParentMapper(); } @@ -1851,7 +1849,7 @@ class DataMapperAbstract implements DataMapperInterface $toFill = null; foreach ($primaryKey as $key => $value) { - if(self::isInitialized(static::class, $value)) { + if (self::isInitialized(static::class, $value)) { continue; } @@ -1862,7 +1860,7 @@ class DataMapperAbstract implements DataMapperInterface $obj[$value] = self::populate(self::getRaw($value), $toFill); - if(method_exists($obj[$value], 'initialize')) { + if (method_exists($obj[$value], 'initialize')) { $obj[$value]->initialize(); } @@ -1874,9 +1872,9 @@ class DataMapperAbstract implements DataMapperInterface $countResulsts = count($obj); - if($countResulsts === 0) { + if ($countResulsts === 0) { return self::getNullModelObj(); - } elseif($countResulsts === 1) { + } elseif ($countResulsts === 1) { return reset($obj); } @@ -1907,7 +1905,7 @@ class DataMapperAbstract implements DataMapperInterface */ public static function getArray($primaryKey, int $relations = RelationType::ALL) : array { - if(!isset(self::$parentMapper)) { + if (!isset(self::$parentMapper)) { self::setUpParentMapper(); } @@ -1917,7 +1915,7 @@ class DataMapperAbstract implements DataMapperInterface $obj = []; foreach ($primaryKey as $key => $value) { - if(self::isInitialized(static::class, $value)) { + if (self::isInitialized(static::class, $value)) { continue; } @@ -1946,7 +1944,7 @@ class DataMapperAbstract implements DataMapperInterface */ public static function getFor($refKey, string $ref, int $relations = RelationType::ALL, $fill = null) { - if(!isset(self::$parentMapper)) { + if (!isset(self::$parentMapper)) { self::setUpParentMapper(); } @@ -1958,7 +1956,7 @@ class DataMapperAbstract implements DataMapperInterface foreach ($refKey as $key => $value) { $toLoad = []; - if(isset(static::$hasMany[$ref]) && static::$hasMany[$ref]['src'] !== null) { + if (isset(static::$hasMany[$ref]) && static::$hasMany[$ref]['src'] !== null) { $toLoad = self::getHasManyPrimaryKeys($value, $ref); } else { $toLoad = self::getPrimaryKeysBy($value, self::getColumnByMember($ref)); @@ -1969,9 +1967,9 @@ class DataMapperAbstract implements DataMapperInterface $countResulsts = count($obj); - if($countResulsts === 0) { + if ($countResulsts === 0) { return self::getNullModelObj(); - } elseif($countResulsts === 1) { + } elseif ($countResulsts === 1) { return reset($obj); } @@ -1992,7 +1990,7 @@ class DataMapperAbstract implements DataMapperInterface */ public static function getForArray($refKey, string $ref, int $relations = RelationType::ALL, $fill = null) { - if(!isset(self::$parentMapper)) { + if (!isset(self::$parentMapper)) { self::setUpParentMapper(); } @@ -2004,7 +2002,7 @@ class DataMapperAbstract implements DataMapperInterface foreach ($refKey as $key => $value) { $toLoad = []; - if(isset(static::$hasMany[$ref]) && static::$hasMany[$ref]['src'] !== null) { + if (isset(static::$hasMany[$ref]) && static::$hasMany[$ref]['src'] !== null) { $toLoad = self::getHasManyPrimaryKeys($value, $ref); } else { $toLoad = self::getPrimaryKeysBy($value, self::getColumnByMember($ref)); @@ -2028,7 +2026,7 @@ class DataMapperAbstract implements DataMapperInterface */ public static function getAll(int $relations = RelationType::ALL, string $lang = '') : array { - if(!isset(self::$parentMapper)) { + if (!isset(self::$parentMapper)) { self::setUpParentMapper(); } @@ -2051,7 +2049,7 @@ class DataMapperAbstract implements DataMapperInterface */ public static function getAllArray(int $relations = RelationType::ALL, string $lang = '') : array { - if(!isset(self::$parentMapper)) { + if (!isset(self::$parentMapper)) { self::setUpParentMapper(); } @@ -2492,7 +2490,7 @@ class DataMapperAbstract implements DataMapperInterface */ private static function addInitialized(string $mapper, $id, $obj = null) /* : void */ { - if(!isset(self::$initObjects[$mapper])) { + if (!isset(self::$initObjects[$mapper])) { self::$initObjects[$mapper] = []; } @@ -2564,8 +2562,8 @@ class DataMapperAbstract implements DataMapperInterface */ private static function getColumnByMember(string $name) : string { - foreach(static::$columns as $cName => $column) { - if($column['internal'] === $name) { + foreach (static::$columns as $cName => $column) { + if ($column['internal'] === $name) { return $cName; } } diff --git a/DataStorage/Database/DataMapperBaseAbstract.php b/DataStorage/Database/DataMapperBaseAbstract.php index 5974cd0a4..032ac4c50 100644 --- a/DataStorage/Database/DataMapperBaseAbstract.php +++ b/DataStorage/Database/DataMapperBaseAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database; @@ -283,7 +283,7 @@ class DataMapperBaseAbstract ]; // clear parent and objects - if(static::class === self::$parentMapper) { + if (static::class === self::$parentMapper) { self::$initObjects = []; self::$parentMapper = null; } @@ -426,8 +426,8 @@ class DataMapperBaseAbstract private static function getColumnByMember(string $name) : string { - foreach(static::$columns as $cName => $column) { - if($column['internal'] === $name) { + foreach (static::$columns as $cName => $column) { + if ($column['internal'] === $name) { return $cName; } } diff --git a/DataStorage/Database/DatabaseExceptionFactory.php b/DataStorage/Database/DatabaseExceptionFactory.php index 99565eb00..8db98d55f 100644 --- a/DataStorage/Database/DatabaseExceptionFactory.php +++ b/DataStorage/Database/DatabaseExceptionFactory.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database; diff --git a/DataStorage/Database/DatabasePool.php b/DataStorage/Database/DatabasePool.php index 5f4751454..a2cb74c4b 100644 --- a/DataStorage/Database/DatabasePool.php +++ b/DataStorage/Database/DatabasePool.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database; @@ -79,11 +79,11 @@ class DatabasePool */ public function get(string $key = '') /* : ?ConnectionAbstract */ { - if((!empty($key) && !isset($this->pool[$key])) || empty($this->pool)) { + if ((!empty($key) && !isset($this->pool[$key])) || empty($this->pool)) { return null; } - if(empty($key)) { + if (empty($key)) { return reset($this->pool); } diff --git a/DataStorage/Database/DatabaseStatus.php b/DataStorage/Database/DatabaseStatus.php index 1a1877a05..56cfd3040 100644 --- a/DataStorage/Database/DatabaseStatus.php +++ b/DataStorage/Database/DatabaseStatus.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database; diff --git a/DataStorage/Database/DatabaseType.php b/DataStorage/Database/DatabaseType.php index 2de4a65c0..9a285fced 100644 --- a/DataStorage/Database/DatabaseType.php +++ b/DataStorage/Database/DatabaseType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database; diff --git a/DataStorage/Database/Exception/InvalidConnectionConfigException.php b/DataStorage/Database/Exception/InvalidConnectionConfigException.php index 5b1a3cef7..0106fdb90 100644 --- a/DataStorage/Database/Exception/InvalidConnectionConfigException.php +++ b/DataStorage/Database/Exception/InvalidConnectionConfigException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Exception; @@ -31,12 +31,12 @@ class InvalidConnectionConfigException extends \InvalidArgumentException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ public function __construct(string $message = '', int $code = 0, \Exception $previous = null) { - parent::__construct('Missing config value for "'. $message .'".', $code, $previous); + parent::__construct('Missing config value for "' . $message . '".', $code, $previous); } } diff --git a/DataStorage/Database/Exception/InvalidMapperException.php b/DataStorage/Database/Exception/InvalidMapperException.php index 240c3b097..9a9023031 100644 --- a/DataStorage/Database/Exception/InvalidMapperException.php +++ b/DataStorage/Database/Exception/InvalidMapperException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Exception; @@ -31,13 +31,13 @@ class InvalidMapperException extends \RuntimeException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ public function __construct(string $message = '', int $code = 0, \Exception $previous = null) { - if($message === '') { + if ($message === '') { parent::__construct('Empty mapper.', $code, $previous); } else { parent::__construct('Mapper "' . $message . '" is invalid.', $code, $previous); diff --git a/DataStorage/Database/GrammarAbstract.php b/DataStorage/Database/GrammarAbstract.php index bd5bcc1c3..dade99a6a 100644 --- a/DataStorage/Database/GrammarAbstract.php +++ b/DataStorage/Database/GrammarAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database; @@ -170,7 +170,7 @@ abstract class GrammarAbstract foreach ($elements as $key => $element) { if (is_string($element) && $element !== '*') { - if(strpos($element, '.') === false) { + if (strpos($element, '.') === false) { $prefix = ''; } @@ -237,8 +237,8 @@ abstract class GrammarAbstract // todo: this is a bad way to handle select count(*) which doesn't need a prefix. Maybe remove prefixes in total? $identifier = $this->systemIdentifier; - foreach($this->specialKeywords as $keyword) { - if($keyword === '' || strrpos($system, $keyword, -strlen($system)) !== false) { + foreach ($this->specialKeywords as $keyword) { + if ($keyword === '' || strrpos($system, $keyword, -strlen($system)) !== false) { $prefix = ''; $identifier = ''; } diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index 996b6a15b..1ffccdac0 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query; @@ -152,7 +152,7 @@ class Builder extends BuilderAbstract /** * Offset. * - * @var array + * @var int * @since 1.0.0 */ public $offset = null; @@ -184,7 +184,7 @@ class Builder extends BuilderAbstract /** * Raw query. * - * @var bool + * @var string * @since 1.0.0 */ public $raw = ''; @@ -356,17 +356,8 @@ class Builder extends BuilderAbstract */ public function raw(string $raw) : Builder { - if($this->isReadOnly) { - $test = strtolower($raw); - - if(strpos($test, 'insert') !== false - || strpos($test, 'update') !== false - || strpos($test, 'drop') !== false - || strpos($test, 'delete') !== false - || strpos($test, 'create') !== false - || strpos($test, 'alter') !== false) { - throw new \Exception(); - } + if (!$this->isValidReadOnly($raw)) { + throw new \Exception(); } $this->type = QueryType::RAW; @@ -375,6 +366,37 @@ class Builder extends BuilderAbstract return $this; } + /** + * Tests if a string contains a non read only component in case the builder is read only. + * If the builder is not read only it will always return true + * + * @param string $raw Raw query + * + * @return bool + * + * @since 1.0.0 + */ + private function isValidReadOnly($raw) : bool + { + if (!$this->isReadOnly) { + return true; + } + + $test = strtolower($raw); + + if (strpos($test, 'insert') !== false + || strpos($test, 'update') !== false + || strpos($test, 'drop') !== false + || strpos($test, 'delete') !== false + || strpos($test, 'create') !== false + || strpos($test, 'alter') !== false + ) { + return false; + } + + return true; + } + /** * Make raw column selection. * @@ -459,36 +481,31 @@ class Builder extends BuilderAbstract */ public function where($columns, $operator = null, $values = null, $boolean = 'and') : Builder { - // TODO: handle $value is null -> operator NULL if (isset($operator) && !is_array($operator) && !in_array(strtolower($operator), self::OPERATORS)) { throw new \InvalidArgumentException('Unknown operator.'); } - if (is_array($columns)) { - $i = 0; - foreach ($columns as $key => $column) { - if (isset($operator[$i]) && !in_array(strtolower($operator[$i]), self::OPERATORS)) { - throw new \InvalidArgumentException('Unknown operator.'); - } + if (is_string($columns)) { + $colums = [$columns]; + $operator = [$operator]; + $values = [$values]; + $boolean = [$boolean]; + } - $this->wheres[self::getPublicColumnName($column)][] = [ - 'column' => $column, - 'operator' => $operator[$i], - 'value' => $values[$i], - 'boolean' => $boolean[$i], - ]; - - $i++; - } - } elseif (is_string($columns)) { - if (isset($operator) && !in_array(strtolower($operator), self::OPERATORS)) { + $i = 0; + foreach ($columns as $key => $column) { + if (isset($operator[$i]) && !in_array(strtolower($operator[$i]), self::OPERATORS)) { throw new \InvalidArgumentException('Unknown operator.'); } - $this->wheres[self::getPublicColumnName($columns)][] = ['column' => $columns, 'operator' => $operator, 'value' => $values, - 'boolean' => $boolean,]; - } else { - throw new \InvalidArgumentException(); + $this->wheres[self::getPublicColumnName($column)][] = [ + 'column' => $column, + 'operator' => $operator[$i], + 'value' => $values[$i], + 'boolean' => $boolean[$i], + ]; + + $i++; } return $this; @@ -523,7 +540,7 @@ class Builder extends BuilderAbstract */ public function getTableOfSystem($expression, string $systemIdentifier) /* : ?string */ { - if(($pos = strpos($expression, $systemIdentifier . '.' . $systemIdentifier)) === false) { + if (($pos = strpos($expression, $systemIdentifier . '.' . $systemIdentifier)) === false) { return null; } @@ -677,7 +694,7 @@ class Builder extends BuilderAbstract public function orderBy($columns, $order = 'DESC') : Builder { if (is_string($columns) || $columns instanceof \Closure) { - if(!isset($this->orders[$order])) { + if (!isset($this->orders[$order])) { $this->orders[$order] = []; } @@ -840,7 +857,7 @@ class Builder extends BuilderAbstract */ public function insert(...$columns) : Builder { - if($this->isReadOnly) { + if ($this->isReadOnly) { throw new \Exception(); } @@ -949,7 +966,7 @@ class Builder extends BuilderAbstract */ public function update(...$tables) : Builder { - if($this->isReadOnly) { + if ($this->isReadOnly) { throw new \Exception(); } @@ -968,7 +985,7 @@ class Builder extends BuilderAbstract public function delete() : Builder { - if($this->isReadOnly) { + if ($this->isReadOnly) { throw new \Exception(); } @@ -1099,7 +1116,7 @@ class Builder extends BuilderAbstract { $sth = $this->connection->con->prepare($this->toSql()); - foreach($this->binds as $key => $bind) { + foreach ($this->binds as $key => $bind) { $type = self::getBindParamType($bind); $sth->bindParam($key, $bind, $type); @@ -1119,9 +1136,9 @@ class Builder extends BuilderAbstract */ public static function getBindParamType($value) { - if(is_int($value)) { + if (is_int($value)) { return PDO::PARAM_INT; - } elseif(is_string($value) || is_float($value)) { + } elseif (is_string($value) || is_float($value)) { return PDO::PARAM_STR; } @@ -1130,13 +1147,13 @@ class Builder extends BuilderAbstract public static function getPublicColumnName($column) : string { - if(is_string($column)) { + if (is_string($column)) { return $column; - } elseif($column instanceof Column) { + } elseif ($column instanceof Column) { return $column->getPublicName(); - } elseif($column instanceof \Closure) { + } elseif ($column instanceof \Closure) { return $column(); - } elseif($column instanceof \Serializable) { + } elseif ($column instanceof \Serializable) { return $column; } diff --git a/DataStorage/Database/Query/Column.php b/DataStorage/Database/Query/Column.php index 7c485668a..c89f07eb2 100644 --- a/DataStorage/Database/Query/Column.php +++ b/DataStorage/Database/Query/Column.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query; diff --git a/DataStorage/Database/Query/Expression.php b/DataStorage/Database/Query/Expression.php index 0a9946fb0..26453de57 100644 --- a/DataStorage/Database/Query/Expression.php +++ b/DataStorage/Database/Query/Expression.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query; diff --git a/DataStorage/Database/Query/Grammar/Grammar.php b/DataStorage/Database/Query/Grammar/Grammar.php index 3ba97ff75..2d4c0f9ed 100644 --- a/DataStorage/Database/Query/Grammar/Grammar.php +++ b/DataStorage/Database/Query/Grammar/Grammar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query\Grammar; @@ -133,7 +133,6 @@ class Grammar extends GrammarAbstract break; case QueryType::RAW: return [$query->raw]; - break; default: throw new \InvalidArgumentException('Unknown query type.'); } @@ -270,7 +269,7 @@ class Grammar extends GrammarAbstract { $expression = ''; - if(!$first) { + if (!$first) { $expression = ' ' . strtoupper($element['boolean']) . ' '; } @@ -317,7 +316,7 @@ class Grammar extends GrammarAbstract protected function compileValue($value, $prefix = '') : string { if (is_string($value)) { - if(strpos($value, ':') === 0) { + if (strpos($value, ':') === 0) { return $value; } @@ -420,7 +419,7 @@ class Grammar extends GrammarAbstract $expression = ''; foreach ($orders as $key => $order) { - foreach($order as $column) { + foreach ($order as $column) { $expression .= $this->compileSystem($column, $query->getPrefix()) . ', '; } diff --git a/DataStorage/Database/Query/Grammar/GrammarInterface.php b/DataStorage/Database/Query/Grammar/GrammarInterface.php index 234da813f..d424598b0 100644 --- a/DataStorage/Database/Query/Grammar/GrammarInterface.php +++ b/DataStorage/Database/Query/Grammar/GrammarInterface.php @@ -11,10 +11,10 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query\Grammar; -class GrammarInterface +interface GrammarInterface { } diff --git a/DataStorage/Database/Query/Grammar/MicrosoftGrammar.php b/DataStorage/Database/Query/Grammar/MicrosoftGrammar.php index 00214fbb5..ec4755213 100644 --- a/DataStorage/Database/Query/Grammar/MicrosoftGrammar.php +++ b/DataStorage/Database/Query/Grammar/MicrosoftGrammar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query\Grammar; use phpOMS\DataStorage\Database\Query\Builder; diff --git a/DataStorage/Database/Query/Grammar/MysqlGrammar.php b/DataStorage/Database/Query/Grammar/MysqlGrammar.php index 082535a71..f442a8d6b 100644 --- a/DataStorage/Database/Query/Grammar/MysqlGrammar.php +++ b/DataStorage/Database/Query/Grammar/MysqlGrammar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query\Grammar; use phpOMS\DataStorage\Database\Query\Builder; diff --git a/DataStorage/Database/Query/Grammar/OracleGrammar.php b/DataStorage/Database/Query/Grammar/OracleGrammar.php index df49c2ea4..2b3c0fe29 100644 --- a/DataStorage/Database/Query/Grammar/OracleGrammar.php +++ b/DataStorage/Database/Query/Grammar/OracleGrammar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query\Grammar; use phpOMS\DataStorage\Database\Query\Builder; diff --git a/DataStorage/Database/Query/Grammar/PostgresGrammar.php b/DataStorage/Database/Query/Grammar/PostgresGrammar.php index a29215e9f..c882e2fa1 100644 --- a/DataStorage/Database/Query/Grammar/PostgresGrammar.php +++ b/DataStorage/Database/Query/Grammar/PostgresGrammar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query\Grammar; use phpOMS\DataStorage\Database\Query\Builder; diff --git a/DataStorage/Database/Query/Grammar/SQLiteGrammar.php b/DataStorage/Database/Query/Grammar/SQLiteGrammar.php index 80d950103..fa28fbb3b 100644 --- a/DataStorage/Database/Query/Grammar/SQLiteGrammar.php +++ b/DataStorage/Database/Query/Grammar/SQLiteGrammar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query\Grammar; use phpOMS\DataStorage\Database\Query\Builder; diff --git a/DataStorage/Database/Query/JoinType.php b/DataStorage/Database/Query/JoinType.php index 449a165cd..70042ffec 100644 --- a/DataStorage/Database/Query/JoinType.php +++ b/DataStorage/Database/Query/JoinType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query; diff --git a/DataStorage/Database/Query/QueryType.php b/DataStorage/Database/Query/QueryType.php index 40481343b..b49736761 100644 --- a/DataStorage/Database/Query/QueryType.php +++ b/DataStorage/Database/Query/QueryType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query; diff --git a/DataStorage/Database/Query/Where.php b/DataStorage/Database/Query/Where.php index d2af3ccd0..fc4a42d57 100644 --- a/DataStorage/Database/Query/Where.php +++ b/DataStorage/Database/Query/Where.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Query; diff --git a/DataStorage/Database/RelationType.php b/DataStorage/Database/RelationType.php index 2ce47c83c..49cfd33be 100644 --- a/DataStorage/Database/RelationType.php +++ b/DataStorage/Database/RelationType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database; diff --git a/DataStorage/Database/Schema/Builder.php b/DataStorage/Database/Schema/Builder.php index c330dcf38..d9f2b69f0 100644 --- a/DataStorage/Database/Schema/Builder.php +++ b/DataStorage/Database/Schema/Builder.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Schema; diff --git a/DataStorage/Database/Schema/Exception/TableException.php b/DataStorage/Database/Schema/Exception/TableException.php index b69bc0cc9..0c0516a2c 100644 --- a/DataStorage/Database/Schema/Exception/TableException.php +++ b/DataStorage/Database/Schema/Exception/TableException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Schema\Exception; @@ -31,7 +31,7 @@ class TableException extends \PDOException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/DataStorage/Database/Schema/Grammar/Grammar.php b/DataStorage/Database/Schema/Grammar/Grammar.php index 406c92f4d..04d302ed5 100644 --- a/DataStorage/Database/Schema/Grammar/Grammar.php +++ b/DataStorage/Database/Schema/Grammar/Grammar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Schema\Grammar; diff --git a/DataStorage/Database/Schema/Grammar/GrammarInterface.php b/DataStorage/Database/Schema/Grammar/GrammarInterface.php index b3dc4695e..5c8f50429 100644 --- a/DataStorage/Database/Schema/Grammar/GrammarInterface.php +++ b/DataStorage/Database/Schema/Grammar/GrammarInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Schema\Grammar; diff --git a/DataStorage/Database/Schema/Grammar/MysqlGrammar.php b/DataStorage/Database/Schema/Grammar/MysqlGrammar.php index 53f4102c8..38e00d3e0 100644 --- a/DataStorage/Database/Schema/Grammar/MysqlGrammar.php +++ b/DataStorage/Database/Schema/Grammar/MysqlGrammar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Schema\Grammar; diff --git a/DataStorage/Database/Schema/Grammar/PostgresGrammar.php b/DataStorage/Database/Schema/Grammar/PostgresGrammar.php index fb6868741..ff4181915 100644 --- a/DataStorage/Database/Schema/Grammar/PostgresGrammar.php +++ b/DataStorage/Database/Schema/Grammar/PostgresGrammar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Schema\Grammar; diff --git a/DataStorage/Database/Schema/Grammar/SQLiteGrammar.php b/DataStorage/Database/Schema/Grammar/SQLiteGrammar.php index 864ea36cd..a67319be6 100644 --- a/DataStorage/Database/Schema/Grammar/SQLiteGrammar.php +++ b/DataStorage/Database/Schema/Grammar/SQLiteGrammar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Schema\Grammar; diff --git a/DataStorage/Database/Schema/Grammar/SqlServerGrammar.php b/DataStorage/Database/Schema/Grammar/SqlServerGrammar.php index c9ee5d5b8..80f443097 100644 --- a/DataStorage/Database/Schema/Grammar/SqlServerGrammar.php +++ b/DataStorage/Database/Schema/Grammar/SqlServerGrammar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Schema\Grammar; diff --git a/DataStorage/Database/Schema/QueryType.php b/DataStorage/Database/Schema/QueryType.php index 98cbba489..42232ad59 100644 --- a/DataStorage/Database/Schema/QueryType.php +++ b/DataStorage/Database/Schema/QueryType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Database\Schema; diff --git a/DataStorage/LockException.php b/DataStorage/LockException.php index b00a96209..3cfd4f3e3 100644 --- a/DataStorage/LockException.php +++ b/DataStorage/LockException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage; @@ -31,7 +31,7 @@ class LockException extends \RuntimeException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/DataStorage/Session/ConsoleSession.php b/DataStorage/Session/ConsoleSession.php index 70b2a09f9..0cee1a8e6 100644 --- a/DataStorage/Session/ConsoleSession.php +++ b/DataStorage/Session/ConsoleSession.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Session; diff --git a/DataStorage/Session/HttpSession.php b/DataStorage/Session/HttpSession.php index 8101b7553..6844132f8 100644 --- a/DataStorage/Session/HttpSession.php +++ b/DataStorage/Session/HttpSession.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Session; @@ -86,12 +86,12 @@ class HttpSession implements SessionInterface $this->inactivityInterval = $inactivityInterval; - if(session_status() !== PHP_SESSION_ACTIVE && !headers_sent()) { + if (session_status() !== PHP_SESSION_ACTIVE && !headers_sent()) { session_set_cookie_params($liftetime, '/', '', false, true); session_start(); } - if($this->inactivityInterval > 0 && ($this->inactivityInterval + ($_SESSION['lastActivity'] ?? 0) < time())) { + if ($this->inactivityInterval > 0 && ($this->inactivityInterval + ($_SESSION['lastActivity'] ?? 0) < time())) { $this->destroy(); } @@ -169,7 +169,7 @@ class HttpSession implements SessionInterface */ public function save() /* : void */ { - if(!self::$isLocked) { + if (!self::$isLocked) { $_SESSION = $this->sessionData; session_write_close(); } diff --git a/DataStorage/Session/SessionInterface.php b/DataStorage/Session/SessionInterface.php index d69d2e427..f4f5a04a2 100644 --- a/DataStorage/Session/SessionInterface.php +++ b/DataStorage/Session/SessionInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Session; diff --git a/DataStorage/Session/SocketSession.php b/DataStorage/Session/SocketSession.php index 464068d6e..8b6b5e2a5 100644 --- a/DataStorage/Session/SocketSession.php +++ b/DataStorage/Session/SocketSession.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\DataStorage\Session; diff --git a/DataStorage/Web/Builder.php b/DataStorage/Web/Builder.php index cef7ce903..31d2e092b 100644 --- a/DataStorage/Web/Builder.php +++ b/DataStorage/Web/Builder.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Crawler; use phpOMs\DataStorage\Database\Query\Builder as DatabaseQueryBuilder; @@ -33,7 +33,7 @@ class Builder extends DatabaseQueryBuilder $finder = []; $l11n = new Localization(); - foreach($this->from as $from) { + foreach ($this->from as $from) { $doc = new \DOMDocument(); $doc->loadHTML(Rest::request($l11n, new Http($from))); $finder[$from] = new \DomXPath($doc); @@ -53,21 +53,21 @@ class Builder extends DatabaseQueryBuilder $result = []; $table = null; - foreach($this->wheres as $column => $where) { - if($column === 'xpath') { + foreach ($this->wheres as $column => $where) { + if ($column === 'xpath') { $table = $this->createTable($finder->query($where['value'])); } } - foreach($this->columns as $column) { + foreach ($this->columns as $column) { } } private function createTable($node) : array { - if(strtolower($node->tagName) === 'table') { + if (strtolower($node->tagName) === 'table') { return $this->createTableFromTable(); - } elseif(strtolower($node->tagName) === 'li') { + } elseif (strtolower($node->tagName) === 'li') { return $this->createTableFromList(); } else { return $this->createTableFromContent(); @@ -88,7 +88,7 @@ class Builder extends DatabaseQueryBuilder $table = []; $children = $node->childNodes; - foreach($children as $child) { + foreach ($children as $child) { $table[] = $child->asXML(); } diff --git a/Dispatcher/Dispatcher.php b/Dispatcher/Dispatcher.php index ba8786ae8..ac7e35e1c 100644 --- a/Dispatcher/Dispatcher.php +++ b/Dispatcher/Dispatcher.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Dispatcher; @@ -175,7 +175,7 @@ class Dispatcher } // If module controller use module manager for initialization - if(strpos('\Modules\Controller', $controller) === 0) { + if (strpos('\Modules\Controller', $controller) === 0) { $split = explode('\\', $controller); $this->controllers[$controller] = $this->app->moduleManager->get($split[2]); } else { diff --git a/Event/EventManager.php b/Event/EventManager.php index ecdd60481..8f9a5fde1 100644 --- a/Event/EventManager.php +++ b/Event/EventManager.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Event; @@ -89,7 +89,7 @@ class EventManager */ public function trigger(string $group, string $id = '', $data = null) : bool { - if(!isset($this->callbacks[$group])) { + if (!isset($this->callbacks[$group])) { return false; } @@ -102,7 +102,7 @@ class EventManager if ($this->callbacks[$group]['remove']) { $this->detach($group); - } elseif($this->callbacks[$group]['reset']) { + } elseif ($this->callbacks[$group]['reset']) { $this->reset($group); } @@ -123,7 +123,7 @@ class EventManager */ private function reset(string $group) /* : void */ { - foreach($this->groups[$group] as $id => $ok) { + foreach ($this->groups[$group] as $id => $ok) { $this->groups[$group][$id] = false; } } @@ -139,12 +139,12 @@ class EventManager */ private function hasOutstanding(string $group) : bool { - if(!isset($this->groups[$group])) { + if (!isset($this->groups[$group])) { return false; } - foreach($this->groups[$group] as $id => $ok) { - if(!$ok) { + foreach ($this->groups[$group] as $id => $ok) { + if (!$ok) { return true; } } diff --git a/Localization/ISO3166CharEnum.php b/Localization/ISO3166CharEnum.php index 02cf06b0b..9e8462243 100644 --- a/Localization/ISO3166CharEnum.php +++ b/Localization/ISO3166CharEnum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO3166NameEnum.php b/Localization/ISO3166NameEnum.php index f85eecfbe..f344ebe39 100644 --- a/Localization/ISO3166NameEnum.php +++ b/Localization/ISO3166NameEnum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO3166NumEnum.php b/Localization/ISO3166NumEnum.php index 5ba84a9a7..e34548b0c 100644 --- a/Localization/ISO3166NumEnum.php +++ b/Localization/ISO3166NumEnum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO3166TwoEnum.php b/Localization/ISO3166TwoEnum.php index 68a4162bc..fc0159a09 100644 --- a/Localization/ISO3166TwoEnum.php +++ b/Localization/ISO3166TwoEnum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO4217CharEnum.php b/Localization/ISO4217CharEnum.php index 03ce8bb89..b7b3d2a6a 100644 --- a/Localization/ISO4217CharEnum.php +++ b/Localization/ISO4217CharEnum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO4217DecimalEnum.php b/Localization/ISO4217DecimalEnum.php index 416ee7aaa..63d2906bc 100644 --- a/Localization/ISO4217DecimalEnum.php +++ b/Localization/ISO4217DecimalEnum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO4217Enum.php b/Localization/ISO4217Enum.php index 09cced948..2b4ed8704 100644 --- a/Localization/ISO4217Enum.php +++ b/Localization/ISO4217Enum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO4217NumEnum.php b/Localization/ISO4217NumEnum.php index b3c574bb7..7937d68c6 100644 --- a/Localization/ISO4217NumEnum.php +++ b/Localization/ISO4217NumEnum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO4217SubUnitEnum.php b/Localization/ISO4217SubUnitEnum.php index 391b8ffc4..2d28018ac 100644 --- a/Localization/ISO4217SubUnitEnum.php +++ b/Localization/ISO4217SubUnitEnum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO4217SymbolEnum.php b/Localization/ISO4217SymbolEnum.php index c4ae80496..bb8fa3312 100644 --- a/Localization/ISO4217SymbolEnum.php +++ b/Localization/ISO4217SymbolEnum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO639Enum.php b/Localization/ISO639Enum.php index 110c3216f..0f6aee0c0 100644 --- a/Localization/ISO639Enum.php +++ b/Localization/ISO639Enum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO639x1Enum.php b/Localization/ISO639x1Enum.php index f88b890cf..bebfd8bb8 100644 --- a/Localization/ISO639x1Enum.php +++ b/Localization/ISO639x1Enum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO639x2Enum.php b/Localization/ISO639x2Enum.php index f5cb1cfed..4b8d2d0a5 100644 --- a/Localization/ISO639x2Enum.php +++ b/Localization/ISO639x2Enum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/ISO8601EnumArray.php b/Localization/ISO8601EnumArray.php index 2524fb9d8..7227bbf97 100644 --- a/Localization/ISO8601EnumArray.php +++ b/Localization/ISO8601EnumArray.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/L11nManager.php b/Localization/L11nManager.php index c4157e707..ca7fb1ff7 100644 --- a/Localization/L11nManager.php +++ b/Localization/L11nManager.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; @@ -160,7 +160,7 @@ class L11nManager if (!isset($this->language[$code][$module][$translation])) { return 'ERROR'; } - } catch(\Exception $e) { + } catch (\Exception $e) { FileLogger::getInstance()->warning(FileLogger::MSG_FULL, [ 'message' => 'Undefined translation for \'' . $code . '/' . $module . '/' . $translation . '\'.', ]); diff --git a/Localization/Localization.php b/Localization/Localization.php index 3982f65a4..8434c5886 100644 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/Money.php b/Localization/Money.php index 3d805fbe0..0ced0e1f2 100644 --- a/Localization/Money.php +++ b/Localization/Money.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/NullLocalization.php b/Localization/NullLocalization.php index 15d21810d..d72281a14 100644 --- a/Localization/NullLocalization.php +++ b/Localization/NullLocalization.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/PhoneEnum.php b/Localization/PhoneEnum.php index 9cc663db8..3007e055f 100644 --- a/Localization/PhoneEnum.php +++ b/Localization/PhoneEnum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Localization/TimeZoneEnumArray.php b/Localization/TimeZoneEnumArray.php index 0c5ea8276..2705cd1a3 100644 --- a/Localization/TimeZoneEnumArray.php +++ b/Localization/TimeZoneEnumArray.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Localization; diff --git a/Log/FileLogger.php b/Log/FileLogger.php index 4bdbe4461..4be39032c 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Log; @@ -180,7 +180,7 @@ class FileLogger implements LoggerInterface */ public static function startTimeLog($id = '') : bool { - if(isset(self::$timings[$id])) { + if (isset(self::$timings[$id])) { return false; } @@ -265,7 +265,7 @@ class FileLogger implements LoggerInterface private function write(string $message) /* : void */ { $this->createFile(); - if(!is_writable($this->path)) { + if (!is_writable($this->path)) { return; } diff --git a/Log/LogLevel.php b/Log/LogLevel.php index c12411d4d..ef359efff 100644 --- a/Log/LogLevel.php +++ b/Log/LogLevel.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Log; diff --git a/Log/LoggerInterface.php b/Log/LoggerInterface.php index 574763d69..e82038945 100644 --- a/Log/LoggerInterface.php +++ b/Log/LoggerInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Log; diff --git a/Math/Differential/FiniteDifference.php b/Math/Differential/FiniteDifference.php index 892c93f4e..927df0585 100644 --- a/Math/Differential/FiniteDifference.php +++ b/Math/Differential/FiniteDifference.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Differential; diff --git a/Math/Exception/ZeroDevisionException.php b/Math/Exception/ZeroDevisionException.php index 74bad5cfd..50c86a992 100644 --- a/Math/Exception/ZeroDevisionException.php +++ b/Math/Exception/ZeroDevisionException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Exception; @@ -31,7 +31,7 @@ class ZeroDevisionException extends \UnexpectedValueException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/Math/Functions/Fibunacci.php b/Math/Functions/Fibunacci.php index e886f9c4f..91f5b91f1 100644 --- a/Math/Functions/Fibunacci.php +++ b/Math/Functions/Fibunacci.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Functions; diff --git a/Math/Functions/Functions.php b/Math/Functions/Functions.php index 564f52aa0..a0a48edb9 100644 --- a/Math/Functions/Functions.php +++ b/Math/Functions/Functions.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Functions; @@ -250,15 +250,15 @@ class Functions * @example The relative fiscal month (August) in a company where the fiscal year starts in July. * @example 2 = getRelativeDegree(8, 12, 7); * - * @param mixed $value Value to get degree - * @param mixed $length Circle size - * @param mixed $start Start value + * @param int $value Value to get degree + * @param int $length Circle size + * @param int $start Start value * * @return int Lowest value is 0 and highest value is length - 1 * * @since 1.0.0 */ - public static function getRelativeDegree($value, $length, $start = 0) : int + public static function getRelativeDegree(int $value, int $length, int $start = 0) : int { return abs(self::mod($value - $start, $length)); } diff --git a/Math/Geometry/ConvexHull/MonotoneChain.php b/Math/Geometry/ConvexHull/MonotoneChain.php index 36d375c13..f16cb8c46 100644 --- a/Math/Geometry/ConvexHull/MonotoneChain.php +++ b/Math/Geometry/ConvexHull/MonotoneChain.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\ConvexHull; @@ -55,7 +55,7 @@ final class MonotoneChain } // Upper hull - for ($i = $n - 2, $t = $k+1; $i >= 0; $i--) { + for ($i = $n - 2, $t = $k + 1; $i >= 0; $i--) { while ($k >= $t && self::cross($result[$k - 2], $result[$k - 1], $points[$i]) <= 0) { $k--; } @@ -65,7 +65,7 @@ final class MonotoneChain ksort($result); - return array_slice($result, 0, $k-1); + return array_slice($result, 0, $k - 1); } return $points; diff --git a/Math/Geometry/Shape/D2/Circle.php b/Math/Geometry/Shape/D2/Circle.php index 996785427..24aff9e4b 100644 --- a/Math/Geometry/Shape/D2/Circle.php +++ b/Math/Geometry/Shape/D2/Circle.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D2; diff --git a/Math/Geometry/Shape/D2/D2ShapeInterface.php b/Math/Geometry/Shape/D2/D2ShapeInterface.php index 47be0c709..b1d566e9c 100644 --- a/Math/Geometry/Shape/D2/D2ShapeInterface.php +++ b/Math/Geometry/Shape/D2/D2ShapeInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D2; diff --git a/Math/Geometry/Shape/D2/Ellipse.php b/Math/Geometry/Shape/D2/Ellipse.php index 289f1c297..c583fad48 100644 --- a/Math/Geometry/Shape/D2/Ellipse.php +++ b/Math/Geometry/Shape/D2/Ellipse.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D2; diff --git a/Math/Geometry/Shape/D2/Polygon.php b/Math/Geometry/Shape/D2/Polygon.php index a003b6341..43c0c32de 100644 --- a/Math/Geometry/Shape/D2/Polygon.php +++ b/Math/Geometry/Shape/D2/Polygon.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D2; @@ -138,7 +138,8 @@ class Polygon implements D2ShapeInterface * @param array $polygon Polygon definition * * @return int - * + * + * @link http://erich.realtimerendering.com/ptinpoly/ * @since 1.0.0 */ public static function isPointInPolygon(array $point, array $polygon) : int @@ -156,7 +157,7 @@ class Polygon implements D2ShapeInterface } // Inside or ontop? - $countIntersect = 0; + $countIntersect = 0; $polygon_count = count($polygon); // todo: return based on highest possibility not by first match diff --git a/Math/Geometry/Shape/D2/Quadrilateral.php b/Math/Geometry/Shape/D2/Quadrilateral.php index a2eb21912..f592f44c1 100644 --- a/Math/Geometry/Shape/D2/Quadrilateral.php +++ b/Math/Geometry/Shape/D2/Quadrilateral.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D2; class Quadrilateral implements D2ShapeInterface diff --git a/Math/Geometry/Shape/D2/Rectangle.php b/Math/Geometry/Shape/D2/Rectangle.php index 05d43d330..de8c3a77e 100644 --- a/Math/Geometry/Shape/D2/Rectangle.php +++ b/Math/Geometry/Shape/D2/Rectangle.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D2; diff --git a/Math/Geometry/Shape/D2/Trapezoid.php b/Math/Geometry/Shape/D2/Trapezoid.php index a0943ea2b..3f7610769 100644 --- a/Math/Geometry/Shape/D2/Trapezoid.php +++ b/Math/Geometry/Shape/D2/Trapezoid.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D2; diff --git a/Math/Geometry/Shape/D2/Triangle.php b/Math/Geometry/Shape/D2/Triangle.php index 4493d196b..7d41843ed 100644 --- a/Math/Geometry/Shape/D2/Triangle.php +++ b/Math/Geometry/Shape/D2/Triangle.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D2; diff --git a/Math/Geometry/Shape/D3/Cone.php b/Math/Geometry/Shape/D3/Cone.php index 2dc80e45e..d3b4fa3ff 100644 --- a/Math/Geometry/Shape/D3/Cone.php +++ b/Math/Geometry/Shape/D3/Cone.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D3; diff --git a/Math/Geometry/Shape/D3/Cuboid.php b/Math/Geometry/Shape/D3/Cuboid.php index 35ce4f6ae..af67df7c3 100644 --- a/Math/Geometry/Shape/D3/Cuboid.php +++ b/Math/Geometry/Shape/D3/Cuboid.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D3; diff --git a/Math/Geometry/Shape/D3/Cylinder.php b/Math/Geometry/Shape/D3/Cylinder.php index 2062250e0..cc7784f3e 100644 --- a/Math/Geometry/Shape/D3/Cylinder.php +++ b/Math/Geometry/Shape/D3/Cylinder.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D3; diff --git a/Math/Geometry/Shape/D3/D3ShapeInterface.php b/Math/Geometry/Shape/D3/D3ShapeInterface.php index af28edc99..e433e4a27 100644 --- a/Math/Geometry/Shape/D3/D3ShapeInterface.php +++ b/Math/Geometry/Shape/D3/D3ShapeInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D3; diff --git a/Math/Geometry/Shape/D3/Prism.php b/Math/Geometry/Shape/D3/Prism.php index f6ba669a5..87723fec5 100644 --- a/Math/Geometry/Shape/D3/Prism.php +++ b/Math/Geometry/Shape/D3/Prism.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D3; class Prism implements D3ShapeInterface diff --git a/Math/Geometry/Shape/D3/RectangularPyramid.php b/Math/Geometry/Shape/D3/RectangularPyramid.php index 2c437a905..d416d0291 100644 --- a/Math/Geometry/Shape/D3/RectangularPyramid.php +++ b/Math/Geometry/Shape/D3/RectangularPyramid.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D3; diff --git a/Math/Geometry/Shape/D3/Sphere.php b/Math/Geometry/Shape/D3/Sphere.php index 334e872b6..8ccd96521 100644 --- a/Math/Geometry/Shape/D3/Sphere.php +++ b/Math/Geometry/Shape/D3/Sphere.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D3; diff --git a/Math/Geometry/Shape/D3/Tetrahedron.php b/Math/Geometry/Shape/D3/Tetrahedron.php index e50351841..aed272801 100644 --- a/Math/Geometry/Shape/D3/Tetrahedron.php +++ b/Math/Geometry/Shape/D3/Tetrahedron.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape\D3; diff --git a/Math/Geometry/Shape/ShapeInterface.php b/Math/Geometry/Shape/ShapeInterface.php index 8e336e504..59c712d5e 100644 --- a/Math/Geometry/Shape/ShapeInterface.php +++ b/Math/Geometry/Shape/ShapeInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Geometry\Shape; diff --git a/Math/Integral/Gauss.php b/Math/Integral/Gauss.php index 5618df6ba..1f4893a3b 100644 --- a/Math/Integral/Gauss.php +++ b/Math/Integral/Gauss.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Integral; diff --git a/Math/Matrix/CholeskyDecomposition.php b/Math/Matrix/CholeskyDecomposition.php index db2fad264..6cc81d63b 100644 --- a/Math/Matrix/CholeskyDecomposition.php +++ b/Math/Matrix/CholeskyDecomposition.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Matrix; @@ -28,9 +28,9 @@ class CholeskyDecomposition $this->L = $M->toArray(); $this->m = $M->getM(); - for($i = 0; $i < $this->m; ++$i) { - for($j = $i; $j < $this->m; ++$j) { - for($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) { + for ($i = 0; $i < $this->m; ++$i) { + for ($j = $i; $j < $this->m; ++$j) { + for ($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) { $sum -= $this->L[$i][$k] * $this->L[$j][$k]; } if ($i == $j) { @@ -46,7 +46,7 @@ class CholeskyDecomposition } } - for ($k = $i+1; $k < $this->m; ++$k) { + for ($k = $i + 1; $k < $this->m; ++$k) { $this->L[$i][$k] = 0.0; } } diff --git a/Math/Matrix/EigenvalueDecomposition.php b/Math/Matrix/EigenvalueDecomposition.php index e69de29bb..a57ffc644 100644 --- a/Math/Matrix/EigenvalueDecomposition.php +++ b/Math/Matrix/EigenvalueDecomposition.php @@ -0,0 +1,20 @@ +m; ++$i) { $LUrowi = $this->LU[$i]; // Most of the time is spent in the following dot product. - $kmax = min($i,$j); + $kmax = min($i, $j); $s = 0.0; for ($k = 0; $k < $kmax; ++$k) { $s += $LUrowi[$k] * $LUcolj[$k]; @@ -57,7 +57,7 @@ class LUDecomposition } // Find pivot and exchange if necessary. $p = $j; - for ($i = $j+1; $i < $this->m; ++$i) { + for ($i = $j + 1; $i < $this->m; ++$i) { if (abs($LUcolj[$i]) > abs($LUcolj[$p])) { $p = $i; } @@ -75,7 +75,7 @@ class LUDecomposition } // Compute multipliers. if (($j < $this->m) && ($this->LU[$j][$j] != 0.0)) { - for ($i = $j+1; $i < $this->m; ++$i) { + for ($i = $j + 1; $i < $this->m; ++$i) { $this->LU[$i][$j] /= $this->LU[$j][$j]; } } @@ -84,16 +84,18 @@ class LUDecomposition public function getL() { + $L = [[]]; + for ($i = 0; $i < $this->m; ++$i) { - for ($j = 0; $j < $this->n; ++$j) { - if ($i > $j) { - $L[$i][$j] = $this->LU[$i][$j]; - } elseif ($i == $j) { - $L[$i][$j] = 1.0; - } else { - $L[$i][$j] = 0.0; - } - } + for ($j = 0; $j < $this->n; ++$j) { + if ($i > $j) { + $L[$i][$j] = $this->LU[$i][$j]; + } elseif ($i == $j) { + $L[$i][$j] = 1.0; + } else { + $L[$i][$j] = 0.0; + } + } } $matrix = new Matrix(); @@ -104,15 +106,17 @@ class LUDecomposition public function getU() { + $U = [[]]; + for ($i = 0; $i < $this->n; ++$i) { - for ($j = 0; $j < $this->n; ++$j) { - if ($i <= $j) { - $U[$i][$j] = $this->LU[$i][$j]; - } else { - $U[$i][$j] = 0.0; - } - } - } + for ($j = 0; $j < $this->n; ++$j) { + if ($i <= $j) { + $U[$i][$j] = $this->LU[$i][$j]; + } else { + $U[$i][$j] = 0.0; + } + } + } $matrix = new Matrix(); $matrix->setMatrix($U); @@ -128,9 +132,9 @@ class LUDecomposition public function isNonsingular() : bool { for ($j = 0; $j < $this->n; ++$j) { - if ($this->LU[$j][$j] == 0) { - return false; - } + if ($this->LU[$j][$j] == 0) { + return false; + } } return true; @@ -154,14 +158,12 @@ class LUDecomposition if (!$this->isNonsingular()) { } - var_dump($this->piv); - $nx = $B->getM(); - $X = $B->getMatrix($this->piv, 0, $nx-1); + $X = $B->getMatrix($this->piv, 0, $nx - 1); // Solve L*Y = B(piv,:) for ($k = 0; $k < $this->n; ++$k) { - for ($i = $k+1; $i < $this->n; ++$i) { + for ($i = $k + 1; $i < $this->n; ++$i) { for ($j = 0; $j < $nx; ++$j) { $X->A[$i][$j] -= $X->A[$k][$j] * $this->LU[$i][$k]; } @@ -169,7 +171,7 @@ class LUDecomposition } // Solve U*X = Y; - for ($k = $this->n-1; $k >= 0; --$k) { + for ($k = $this->n - 1; $k >= 0; --$k) { for ($j = 0; $j < $nx; ++$j) { $X->A[$k][$j] /= $this->LU[$k][$k]; } diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index c1ef2e473..62f780687 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Matrix; @@ -574,7 +574,7 @@ class Matrix implements \ArrayAccess, \Iterator $mDim = count($b); $matrix = $this->matrix; - for($col = 0; $col < $mDim; $col++) { + for ($col = 0; $col < $mDim; $col++) { $j = $col; $max = $matrix[$j][$j]; @@ -587,7 +587,7 @@ class Matrix implements \ArrayAccess, \Iterator } } - if($col != $j) { + if ($col != $j) { $temp = $matrix[$col]; $matrix[$col] = $matrix[$j]; $matrix[$j] = $temp; diff --git a/Math/Matrix/QRDecomposition.php b/Math/Matrix/QRDecomposition.php index fb735ad08..ee07a89dc 100644 --- a/Math/Matrix/QRDecomposition.php +++ b/Math/Matrix/QRDecomposition.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Matrix; @@ -27,68 +27,70 @@ class QRDecomposition public function __construct(Matrix $M) { // Initialize. - $this->QR = $M->toArray(); - $this->m = $M->getRowDimension(); + $this->QR = $M->toArray(); + $this->m = $M->getRowDimension(); $this->n = $M->getColumnDimension(); - // Main loop. - for ($k = 0; $k < $this->n; ++$k) { - // Compute 2-norm of k-th column without under/overflow. - $nrm = 0.0; - for ($i = $k; $i < $this->m; ++$i) { - $nrm = hypo($nrm, $this->QR[$i][$k]); + // Main loop. + for ($k = 0; $k < $this->n; ++$k) { + // Compute 2-norm of k-th column without under/overflow. + $nrm = 0.0; + for ($i = $k; $i < $this->m; ++$i) { + $nrm = hypo($nrm, $this->QR[$i][$k]); } - if ($nrm != 0.0) { - // Form k-th Householder vector. - if ($this->QR[$k][$k] < 0) { - $nrm = -$nrm; + if ($nrm != 0.0) { + // Form k-th Householder vector. + if ($this->QR[$k][$k] < 0) { + $nrm = -$nrm; } - for ($i = $k; $i < $this->m; ++$i) { - $this->QR[$i][$k] /= $nrm; + for ($i = $k; $i < $this->m; ++$i) { + $this->QR[$i][$k] /= $nrm; } - $this->QR[$k][$k] += 1.0; - // Apply transformation to remaining columns. - for ($j = $k+1; $j < $this->n; ++$j) { + $this->QR[$k][$k] += 1.0; + // Apply transformation to remaining columns. + for ($j = $k + 1; $j < $this->n; ++$j) { $s = 0.0; - for ($i = $k; $i < $this->m; ++$i) { - $s += $this->QR[$i][$k] * $this->QR[$i][$j]; + for ($i = $k; $i < $this->m; ++$i) { + $s += $this->QR[$i][$k] * $this->QR[$i][$j]; } - $s = -$s/$this->QR[$k][$k]; - for ($i = $k; $i < $this->m; ++$i) { - $this->QR[$i][$j] += $s * $this->QR[$i][$k]; - } - } - } + $s = -$s / $this->QR[$k][$k]; + for ($i = $k; $i < $this->m; ++$i) { + $this->QR[$i][$j] += $s * $this->QR[$i][$k]; + } + } + } $this->Rdiag[$k] = -$nrm; - } + } } public function isFullRank() : bool { for ($j = 0; $j < $this->n; ++$j) { - if ($this->Rdiag[$j] == 0) { - return false; - } + if ($this->Rdiag[$j] == 0) { + return false; + } } - return true; + return true; } public function getH() { + $H = [[]]; + for ($i = 0; $i < $this->m; ++$i) { - for ($j = 0; $j < $this->n; ++$j) { - if ($i >= $j) { - $H[$i][$j] = $this->QR[$i][$j]; - } else { - $H[$i][$j] = 0.0; - } - } + for ($j = 0; $j < $this->n; ++$j) { + if ($i >= $j) { + $H[$i][$j] = $this->QR[$i][$j]; + } else { + $H[$i][$j] = 0.0; + } + } } $matrix = new Matrix(); @@ -99,16 +101,18 @@ class QRDecomposition public function getR() { + $R = [[]]; + for ($i = 0; $i < $this->n; ++$i) { - for ($j = 0; $j < $this->n; ++$j) { - if ($i < $j) { - $R[$i][$j] = $this->QR[$i][$j]; - } elseif ($i == $j) { - $R[$i][$j] = $this->Rdiag[$i]; - } else { - $R[$i][$j] = 0.0; - } - } + for ($j = 0; $j < $this->n; ++$j) { + if ($i < $j) { + $R[$i][$j] = $this->QR[$i][$j]; + } elseif ($i == $j) { + $R[$i][$j] = $this->Rdiag[$i]; + } else { + $R[$i][$j] = 0.0; + } + } } $matrix = new Matrix(); @@ -119,24 +123,27 @@ class QRDecomposition public function getQ() { - for ($k = $this->n-1; $k >= 0; --$k) { - for ($i = 0; $i < $this->m; ++$i) { - $Q[$i][$k] = 0.0; - } - $Q[$k][$k] = 1.0; - for ($j = $k; $j < $this->n; ++$j) { - if ($this->QR[$k][$k] != 0) { - $s = 0.0; - for ($i = $k; $i < $this->m; ++$i) { - $s += $this->QR[$i][$k] * $Q[$i][$j]; - } - $s = -$s/$this->QR[$k][$k]; - for ($i = $k; $i < $this->m; ++$i) { - $Q[$i][$j] += $s * $this->QR[$i][$k]; - } - } - } - } + $Q = [[]]; + + for ($k = $this->n - 1; $k >= 0; --$k) { + for ($i = 0; $i < $this->m; ++$i) { + $Q[$i][$k] = 0.0; + } + + $Q[$k][$k] = 1.0; + for ($j = $k; $j < $this->n; ++$j) { + if ($this->QR[$k][$k] != 0) { + $s = 0.0; + for ($i = $k; $i < $this->m; ++$i) { + $s += $this->QR[$i][$k] * $Q[$i][$j]; + } + $s = -$s / $this->QR[$k][$k]; + for ($i = $k; $i < $this->m; ++$i) { + $Q[$i][$j] += $s * $this->QR[$i][$k]; + } + } + } + } $matrix = new Matrix(); $matrix->setArray($Q); @@ -161,20 +168,20 @@ class QRDecomposition for ($i = $k; $i < $this->m; ++$i) { $s += $this->QR[$i][$k] * $X[$i][$j]; } - $s = -$s/$this->QR[$k][$k]; + $s = -$s / $this->QR[$k][$k]; for ($i = $k; $i < $this->m; ++$i) { $X[$i][$j] += $s * $this->QR[$i][$k]; } } } // Solve R*X = Y; - for ($k = $this->n-1; $k >= 0; --$k) { + for ($k = $this->n - 1; $k >= 0; --$k) { for ($j = 0; $j < $nx; ++$j) { $X[$k][$j] /= $this->Rdiag[$k]; } for ($i = 0; $i < $k; ++$i) { for ($j = 0; $j < $nx; ++$j) { - $X[$i][$j] -= $X[$k][$j]* $this->QR[$i][$k]; + $X[$i][$j] -= $X[$k][$j] * $this->QR[$i][$k]; } } } @@ -182,6 +189,6 @@ class QRDecomposition $matrix = new Matrix(); $matrix->setArray($X); - return $matrix->getMatrix(0, $this->n-1, 0, $nx); + return $matrix->getMatrix(0, $this->n - 1, 0, $nx); } } \ No newline at end of file diff --git a/Math/Matrix/SingularValueDecomposition.php b/Math/Matrix/SingularValueDecomposition.php index e69de29bb..8dbe92611 100644 --- a/Math/Matrix/SingularValueDecomposition.php +++ b/Math/Matrix/SingularValueDecomposition.php @@ -0,0 +1,20 @@ +edges = new MultiMap(KeyType::MULTIPLE, OrderType::LOOSE); - } - - /** - * Add vertice to graph. - * - * @param VerticeInterface $vertice Vertice - * - * @return bool - * - * @since 1.0.0 - */ - public function addVertice(VerticeInterface $vertice) : bool - { - if (!isset($this->vertices[$vertice->getId()])) { - $this->vertices[$vertice->getId()] = $vertice; - - return true; - } - - return false; - } - - /** - * Add edge to graph. - * - * @param EdgeInterface $edge Edge - * - * @return bool - * - * @since 1.0.0 - */ - public function addEdge(EdgeInterface $edge) : bool - { - if (!isset($this->edges[$edge->getId()])) { - $this->edges[$edge->getId()] = $edge; - - return true; - } - - return false; - } - - /** - * Remove vertice from graph. - * - * @param mixed $id Id of vertice to remove - * - * @return bool - * - * @since 1.0.0 - */ - public function removeVertice($id) : bool - { - if (isset($this->vertices[$id])) { - unset($this->vertices[$id]); - - return true; - } - - return false; - } - - /** - * Remove edge by nodes from graph. - * - * @param mixed $a First node of edge - * @param mixed $b Second node of edge - * - * @return bool - * - * @since 1.0.0 - */ - public function removeEdge($a, $b) : bool - { - return $this->edges->remove([$a, $b]); - } - - /** - * Remove edge from graph. - * - * @param mixed $id Id of edge to remove - * - * @return bool - * - * @since 1.0.0 - */ - public function removeEdgeById($id) : bool - { - if (isset($this->edges[$id])) { - unset($this->edges[$id]); - - return true; - } - - return false; - } - - /** - * Get vertice. - * - * @param mixed $id Id of vertice - * - * @return VerticeInterface - * - * @since 1.0.0 - */ - public function getVertice($id) : VerticeInterface - { - return $this->vertices[$id] ?? new NullVertice(); - } - - /** - * Get edge by nodes. - * - * Order of nodes is irrelevant - * - * @param mixed $a First node of edge - * @param mixed $b Second node of edge - * - * @return EdgeInterface - * - * @since 1.0.0 - */ - public function getEdge($a, $b) : EdgeInterface - { - return $this->edges->get([$a, $b]) ?? new NullEdge(); - } - - /** - * Get edge by id. - * - * @param int $id Edge id - * - * @return EdgeInterface - * - * @since 1.0.0 - */ - public function getEdgeById(int $id) : EdgeInterface - { - return $this->edges->get($id) ?? new NullEdge(); - } - - /** - * Count vertices. - * - * @return int - * - * @since 1.0.0 - */ - public function countVertices() : int - { - return count($this->vertices); - } - - /** - * Count edges. - * - * @return int - * - * @since 1.0.0 - */ - public function countEdges() : int - { - return count($this->edges); - } -} \ No newline at end of file diff --git a/Math/Optimization/Graph/NullEdge.php b/Math/Optimization/Graph/NullEdge.php index 27c324783..8a0e313fd 100644 --- a/Math/Optimization/Graph/NullEdge.php +++ b/Math/Optimization/Graph/NullEdge.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\Graph; diff --git a/Math/Optimization/Graph/NullVertice.php b/Math/Optimization/Graph/NullVertice.php index 19cb5c5f0..b2c88a2b5 100644 --- a/Math/Optimization/Graph/NullVertice.php +++ b/Math/Optimization/Graph/NullVertice.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\Graph; diff --git a/Math/Optimization/Graph/VerticeInterface.php b/Math/Optimization/Graph/VerticeInterface.php index 4724b5ceb..ca66edbd1 100644 --- a/Math/Optimization/Graph/VerticeInterface.php +++ b/Math/Optimization/Graph/VerticeInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\Graph; diff --git a/Math/Optimization/Knappsack/Backpack.php b/Math/Optimization/Knappsack/Backpack.php index eb15addd1..4c999eb91 100644 --- a/Math/Optimization/Knappsack/Backpack.php +++ b/Math/Optimization/Knappsack/Backpack.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\Knappsack; class Backpack diff --git a/Math/Optimization/Knappsack/BruteForce.php b/Math/Optimization/Knappsack/BruteForce.php index 8887394d1..f0a2cbcfa 100644 --- a/Math/Optimization/Knappsack/BruteForce.php +++ b/Math/Optimization/Knappsack/BruteForce.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\Knappsack; class BruteForce diff --git a/Math/Optimization/Knappsack/GA.php b/Math/Optimization/Knappsack/GA.php index c01faddf3..016bcc678 100644 --- a/Math/Optimization/Knappsack/GA.php +++ b/Math/Optimization/Knappsack/GA.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\Knappsack; class GA diff --git a/Math/Optimization/Knappsack/Item.php b/Math/Optimization/Knappsack/Item.php index 2b396d108..538037980 100644 --- a/Math/Optimization/Knappsack/Item.php +++ b/Math/Optimization/Knappsack/Item.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\Knappsack; class Item diff --git a/Math/Optimization/Knappsack/ItemPool.php b/Math/Optimization/Knappsack/ItemPool.php index 676ad5780..f67633192 100644 --- a/Math/Optimization/Knappsack/ItemPool.php +++ b/Math/Optimization/Knappsack/ItemPool.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\Knappsack; class ItemPool diff --git a/Math/Optimization/Knappsack/Population.php b/Math/Optimization/Knappsack/Population.php index eeb6f279c..69778ed14 100644 --- a/Math/Optimization/Knappsack/Population.php +++ b/Math/Optimization/Knappsack/Population.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\Knappsack; class Population diff --git a/Math/Optimization/ShiftScheduling/BruteForce.php b/Math/Optimization/ShiftScheduling/BruteForce.php index 2e23e980f..b6485cf09 100644 --- a/Math/Optimization/ShiftScheduling/BruteForce.php +++ b/Math/Optimization/ShiftScheduling/BruteForce.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\ShiftScheduling; class BruteForce diff --git a/Math/Optimization/ShiftScheduling/GA.php b/Math/Optimization/ShiftScheduling/GA.php index 86560a2b3..2f28445ff 100644 --- a/Math/Optimization/ShiftScheduling/GA.php +++ b/Math/Optimization/ShiftScheduling/GA.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\ShiftScheduling; class GA diff --git a/Math/Optimization/ShiftScheduling/Population.php b/Math/Optimization/ShiftScheduling/Population.php index ab8bad8c1..cc82abb7d 100644 --- a/Math/Optimization/ShiftScheduling/Population.php +++ b/Math/Optimization/ShiftScheduling/Population.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\ShiftScheduling; class Population diff --git a/Math/Optimization/ShiftScheduling/Workday.php b/Math/Optimization/ShiftScheduling/Workday.php index 482bd43b0..2867b6e10 100644 --- a/Math/Optimization/ShiftScheduling/Workday.php +++ b/Math/Optimization/ShiftScheduling/Workday.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\ShiftScheduling; class Workday diff --git a/Math/Optimization/ShiftScheduling/Worker.php b/Math/Optimization/ShiftScheduling/Worker.php index 2dae946b4..7d94772ca 100644 --- a/Math/Optimization/ShiftScheduling/Worker.php +++ b/Math/Optimization/ShiftScheduling/Worker.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\ShiftScheduling; class Worker diff --git a/Math/Optimization/ShiftScheduling/WorkerPool.php b/Math/Optimization/ShiftScheduling/WorkerPool.php index 64bb3fadd..891819d30 100644 --- a/Math/Optimization/ShiftScheduling/WorkerPool.php +++ b/Math/Optimization/ShiftScheduling/WorkerPool.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\ShiftScheduling; class WorkerPool diff --git a/Math/Optimization/TSP/BruteForce.php b/Math/Optimization/TSP/BruteForce.php index 16a67e3ec..bfefcfb9f 100644 --- a/Math/Optimization/TSP/BruteForce.php +++ b/Math/Optimization/TSP/BruteForce.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\TSP; diff --git a/Math/Optimization/TSP/City.php b/Math/Optimization/TSP/City.php index d2e45f0f7..3b27a6a88 100644 --- a/Math/Optimization/TSP/City.php +++ b/Math/Optimization/TSP/City.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\TSP; diff --git a/Math/Optimization/TSP/CityPool.php b/Math/Optimization/TSP/CityPool.php index 3a3ede868..5e7002bd1 100644 --- a/Math/Optimization/TSP/CityPool.php +++ b/Math/Optimization/TSP/CityPool.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\TSP; diff --git a/Math/Optimization/TSP/GA.php b/Math/Optimization/TSP/GA.php index 0cb2a85b6..cbf3169ca 100644 --- a/Math/Optimization/TSP/GA.php +++ b/Math/Optimization/TSP/GA.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\TSP; diff --git a/Math/Optimization/TSP/Population.php b/Math/Optimization/TSP/Population.php index 52e9bb0a3..7ebecb109 100644 --- a/Math/Optimization/TSP/Population.php +++ b/Math/Optimization/TSP/Population.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\TSP; diff --git a/Math/Optimization/TSP/Tour.php b/Math/Optimization/TSP/Tour.php index a3b719603..4730099a9 100644 --- a/Math/Optimization/TSP/Tour.php +++ b/Math/Optimization/TSP/Tour.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Optimization\TSP; diff --git a/Math/Parser/Evaluator.php b/Math/Parser/Evaluator.php index ce78cc437..cdeefc80d 100644 --- a/Math/Parser/Evaluator.php +++ b/Math/Parser/Evaluator.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Parser; diff --git a/Math/Statistic/Average.php b/Math/Statistic/Average.php index 0bcd1674d..af5351759 100644 --- a/Math/Statistic/Average.php +++ b/Math/Statistic/Average.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic; @@ -52,11 +52,11 @@ class Average * * @since 1.0.0 */ - public static function averageChange(array $x, int $h = 1) : float + public static function averageDatasetChange(array $x, int $h = 1) : float { $count = count($x); - return $x[$count - 1] + $h * ($x[$count - 1] - $x[0]) / ($count - 1); + return $h * ($x[$count - 1] - $x[0]) / ($count - 1); } /** @@ -185,12 +185,12 @@ class Average * * @since 1.0.0 */ - public static function mode($values) + public static function mode(array $values) { $count = array_count_values($values); $best = max($count); - return array_keys($count, $best); + return (float) (array_keys($count, $best)[0] ?? 0.0); } /** diff --git a/Math/Statistic/Basic.php b/Math/Statistic/Basic.php index 090e01cae..8b99cf95b 100644 --- a/Math/Statistic/Basic.php +++ b/Math/Statistic/Basic.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic; diff --git a/Math/Statistic/Correlation.php b/Math/Statistic/Correlation.php index 509118b66..e93e93f87 100644 --- a/Math/Statistic/Correlation.php +++ b/Math/Statistic/Correlation.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic; diff --git a/Math/Statistic/Forecast/Error.php b/Math/Statistic/Forecast/Error.php index 43792db3c..e885d1bce 100644 --- a/Math/Statistic/Forecast/Error.php +++ b/Math/Statistic/Forecast/Error.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic\Forecast; diff --git a/Math/Statistic/Forecast/ForecastIntervalMultiplier.php b/Math/Statistic/Forecast/ForecastIntervalMultiplier.php index a8bddc0fa..960a16b1b 100644 --- a/Math/Statistic/Forecast/ForecastIntervalMultiplier.php +++ b/Math/Statistic/Forecast/ForecastIntervalMultiplier.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic\Forecast; diff --git a/Math/Statistic/Forecast/Forecasts.php b/Math/Statistic/Forecast/Forecasts.php index 6f7765c72..87a4e06c1 100644 --- a/Math/Statistic/Forecast/Forecasts.php +++ b/Math/Statistic/Forecast/Forecasts.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic\Forecast; diff --git a/Math/Statistic/Forecast/Regression/LevelLevelRegression.php b/Math/Statistic/Forecast/Regression/LevelLevelRegression.php index 09cffb4d0..64ecbfeb8 100644 --- a/Math/Statistic/Forecast/Regression/LevelLevelRegression.php +++ b/Math/Statistic/Forecast/Regression/LevelLevelRegression.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic\Forecast\Regression; diff --git a/Math/Statistic/Forecast/Regression/LevelLogRegression.php b/Math/Statistic/Forecast/Regression/LevelLogRegression.php index 94cd2d309..cbc7fbccb 100644 --- a/Math/Statistic/Forecast/Regression/LevelLogRegression.php +++ b/Math/Statistic/Forecast/Regression/LevelLogRegression.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic\Forecast\Regression; diff --git a/Math/Statistic/Forecast/Regression/LogLevelRegression.php b/Math/Statistic/Forecast/Regression/LogLevelRegression.php index c7e99a0ef..2fd5ab87d 100644 --- a/Math/Statistic/Forecast/Regression/LogLevelRegression.php +++ b/Math/Statistic/Forecast/Regression/LogLevelRegression.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic\Forecast\Regression; diff --git a/Math/Statistic/Forecast/Regression/LogLogRegression.php b/Math/Statistic/Forecast/Regression/LogLogRegression.php index fb0f20680..8f8bfa1e7 100644 --- a/Math/Statistic/Forecast/Regression/LogLogRegression.php +++ b/Math/Statistic/Forecast/Regression/LogLogRegression.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic\Forecast\Regression; diff --git a/Math/Statistic/Forecast/Regression/MultipleLinearRegression.php b/Math/Statistic/Forecast/Regression/MultipleLinearRegression.php index ad4781be4..d68611f1b 100644 --- a/Math/Statistic/Forecast/Regression/MultipleLinearRegression.php +++ b/Math/Statistic/Forecast/Regression/MultipleLinearRegression.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic\Forecast\Regression; use phpOMS\Math\Matrix\Matrix; diff --git a/Math/Statistic/Forecast/Regression/RegressionAbstract.php b/Math/Statistic/Forecast/Regression/RegressionAbstract.php index 8c4068702..446f73954 100644 --- a/Math/Statistic/Forecast/Regression/RegressionAbstract.php +++ b/Math/Statistic/Forecast/Regression/RegressionAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic\Forecast\Regression; use phpOMS\Math\Statistic\Average; diff --git a/Math/Statistic/MeasureOfDispersion.php b/Math/Statistic/MeasureOfDispersion.php index 09bc6d104..26ec3a129 100644 --- a/Math/Statistic/MeasureOfDispersion.php +++ b/Math/Statistic/MeasureOfDispersion.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Statistic; @@ -47,7 +47,7 @@ class MeasureOfDispersion $end = end($values); $start = reset($values); - return $start - $end; + return $end - $start; } /** diff --git a/Math/Stochastic/Distribution/BernoulliDistribution.php b/Math/Stochastic/Distribution/BernoulliDistribution.php index 6a6e8dcae..b958fc0fe 100644 --- a/Math/Stochastic/Distribution/BernoulliDistribution.php +++ b/Math/Stochastic/Distribution/BernoulliDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; diff --git a/Math/Stochastic/Distribution/BetaDistribution.php b/Math/Stochastic/Distribution/BetaDistribution.php index e3e9a5598..23164d5ba 100644 --- a/Math/Stochastic/Distribution/BetaDistribution.php +++ b/Math/Stochastic/Distribution/BetaDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; class BetaDistribution diff --git a/Math/Stochastic/Distribution/BinomialDistribution.php b/Math/Stochastic/Distribution/BinomialDistribution.php index 1dbb1bb74..fcb649a0f 100644 --- a/Math/Stochastic/Distribution/BinomialDistribution.php +++ b/Math/Stochastic/Distribution/BinomialDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; diff --git a/Math/Stochastic/Distribution/CauchyDistribution.php b/Math/Stochastic/Distribution/CauchyDistribution.php index 91347b973..24f77c8d5 100644 --- a/Math/Stochastic/Distribution/CauchyDistribution.php +++ b/Math/Stochastic/Distribution/CauchyDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; diff --git a/Math/Stochastic/Distribution/ChiSquaredDistribution.php b/Math/Stochastic/Distribution/ChiSquaredDistribution.php index 0a7afa1d8..54fe8e336 100644 --- a/Math/Stochastic/Distribution/ChiSquaredDistribution.php +++ b/Math/Stochastic/Distribution/ChiSquaredDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; diff --git a/Math/Stochastic/Distribution/ExponentialDistribution.php b/Math/Stochastic/Distribution/ExponentialDistribution.php index 237c62eb7..dd52d24a7 100644 --- a/Math/Stochastic/Distribution/ExponentialDistribution.php +++ b/Math/Stochastic/Distribution/ExponentialDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; diff --git a/Math/Stochastic/Distribution/FDistribution.php b/Math/Stochastic/Distribution/FDistribution.php index df308127b..2e4b1db07 100644 --- a/Math/Stochastic/Distribution/FDistribution.php +++ b/Math/Stochastic/Distribution/FDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; class FDistribution diff --git a/Math/Stochastic/Distribution/GammaDistribution.php b/Math/Stochastic/Distribution/GammaDistribution.php index 10fc9d628..ec473a311 100644 --- a/Math/Stochastic/Distribution/GammaDistribution.php +++ b/Math/Stochastic/Distribution/GammaDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; class GammaDistribution diff --git a/Math/Stochastic/Distribution/GeometricDistribution.php b/Math/Stochastic/Distribution/GeometricDistribution.php index 15ac256bd..80da95c89 100644 --- a/Math/Stochastic/Distribution/GeometricDistribution.php +++ b/Math/Stochastic/Distribution/GeometricDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; diff --git a/Math/Stochastic/Distribution/HypergeometricDistribution.php b/Math/Stochastic/Distribution/HypergeometricDistribution.php index c7df59a02..05d4ef4d6 100644 --- a/Math/Stochastic/Distribution/HypergeometricDistribution.php +++ b/Math/Stochastic/Distribution/HypergeometricDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; class HypergeometricDistribution diff --git a/Math/Stochastic/Distribution/LaplaceDistribution.php b/Math/Stochastic/Distribution/LaplaceDistribution.php index 61b32d8dd..bba8d5089 100644 --- a/Math/Stochastic/Distribution/LaplaceDistribution.php +++ b/Math/Stochastic/Distribution/LaplaceDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; diff --git a/Math/Stochastic/Distribution/LogDistribution.php b/Math/Stochastic/Distribution/LogDistribution.php index f1c3749af..95a454b8b 100644 --- a/Math/Stochastic/Distribution/LogDistribution.php +++ b/Math/Stochastic/Distribution/LogDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; class LogDistribution diff --git a/Math/Stochastic/Distribution/LogNormalDistribution.php b/Math/Stochastic/Distribution/LogNormalDistribution.php index 5aa64e3db..ee3e9dd8a 100644 --- a/Math/Stochastic/Distribution/LogNormalDistribution.php +++ b/Math/Stochastic/Distribution/LogNormalDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; class LogNormalDistribution diff --git a/Math/Stochastic/Distribution/LogisticDistribution.php b/Math/Stochastic/Distribution/LogisticDistribution.php index 482364c66..75022a33f 100644 --- a/Math/Stochastic/Distribution/LogisticDistribution.php +++ b/Math/Stochastic/Distribution/LogisticDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; class LogisticDistribution diff --git a/Math/Stochastic/Distribution/NormalDistribution.php b/Math/Stochastic/Distribution/NormalDistribution.php index 6a8c45631..4a7c7e184 100644 --- a/Math/Stochastic/Distribution/NormalDistribution.php +++ b/Math/Stochastic/Distribution/NormalDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; diff --git a/Math/Stochastic/Distribution/ParetoDistribution.php b/Math/Stochastic/Distribution/ParetoDistribution.php index 7464a7c1f..20370e030 100644 --- a/Math/Stochastic/Distribution/ParetoDistribution.php +++ b/Math/Stochastic/Distribution/ParetoDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; class ParetoDistribution diff --git a/Math/Stochastic/Distribution/PoissonDistribution.php b/Math/Stochastic/Distribution/PoissonDistribution.php index e901576fa..d179d1e29 100644 --- a/Math/Stochastic/Distribution/PoissonDistribution.php +++ b/Math/Stochastic/Distribution/PoissonDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; diff --git a/Math/Stochastic/Distribution/TDistribution.php b/Math/Stochastic/Distribution/TDistribution.php index 19f51ae9e..896bab1f6 100644 --- a/Math/Stochastic/Distribution/TDistribution.php +++ b/Math/Stochastic/Distribution/TDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; class TDistribution diff --git a/Math/Stochastic/Distribution/UniformDistributionContinuous.php b/Math/Stochastic/Distribution/UniformDistributionContinuous.php index cc90f439d..7a3dfa21b 100644 --- a/Math/Stochastic/Distribution/UniformDistributionContinuous.php +++ b/Math/Stochastic/Distribution/UniformDistributionContinuous.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; diff --git a/Math/Stochastic/Distribution/UniformDistributionDiscrete.php b/Math/Stochastic/Distribution/UniformDistributionDiscrete.php index 93fbe39a6..844980202 100644 --- a/Math/Stochastic/Distribution/UniformDistributionDiscrete.php +++ b/Math/Stochastic/Distribution/UniformDistributionDiscrete.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; diff --git a/Math/Stochastic/Distribution/WeibullDistribution.php b/Math/Stochastic/Distribution/WeibullDistribution.php index 9b7e8296e..8b62f3528 100644 --- a/Math/Stochastic/Distribution/WeibullDistribution.php +++ b/Math/Stochastic/Distribution/WeibullDistribution.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic\Distribution; class WeibullDistribution diff --git a/Math/Stochastic/NaiveBayesFilter.php b/Math/Stochastic/NaiveBayesFilter.php index e16a98450..e66fd67c7 100644 --- a/Math/Stochastic/NaiveBayesFilter.php +++ b/Math/Stochastic/NaiveBayesFilter.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Math\Stochastic; /** * Bernulli distribution. @@ -43,13 +43,13 @@ class NaiveBayesFilter $normalizedDict = $this->normalizeDictionary(); $n = 0.0; - foreach($toMatch as $element) { - if(isset($normalizedDict[$element])) { - $n += log(1-$normalizedDict[$element]['match'] / $normalizedDict[$element]['total']) - log($normalizedDict[$element]['match'] / $normalizedDict[$element]['total']); + foreach ($toMatch as $element) { + if (isset($normalizedDict[$element])) { + $n += log(1 - $normalizedDict[$element]['match'] / $normalizedDict[$element]['total']) - log($normalizedDict[$element]['match'] / $normalizedDict[$element]['total']); } } - return 1 / (1+exp($n)); + return 1 / (1 + exp($n)); } private function normalizeDictionary() : array diff --git a/Message/HeaderAbstract.php b/Message/HeaderAbstract.php index dc7881e8b..100f1788b 100644 --- a/Message/HeaderAbstract.php +++ b/Message/HeaderAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message; diff --git a/Message/Http/BrowserType.php b/Message/Http/BrowserType.php index 1fa9b75dd..84139d58a 100644 --- a/Message/Http/BrowserType.php +++ b/Message/Http/BrowserType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Http; diff --git a/Message/Http/Header.php b/Message/Http/Header.php index b5d9e4330..131725aca 100644 --- a/Message/Http/Header.php +++ b/Message/Http/Header.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Http; @@ -71,18 +71,18 @@ class Header extends HeaderAbstract throw new LockException('HTTP header'); } + if (self::isSecurityHeader($key) && isset($this->header[$key])) { + throw new \Exception('Cannot change security headers.'); + } + $key = strtolower($key); if (!$overwrite && isset($this->header[$key])) { return false; - } elseif ($overwrite || !isset($this->header[$key])) { - if (self::isSecurityHeader($key) && isset($this->header[$key])) { - throw new \Exception('Cannot change security headers.'); - } - - unset($this->header[$key]); } + unset($this->header[$key]); + if (!isset($this->header[$key])) { $this->header[$key] = []; } @@ -128,7 +128,7 @@ class Header extends HeaderAbstract */ public function getStatusCode() : int { - if($this->status === 0) { + if ($this->status === 0) { $this->status = (int) \http_response_code(); } diff --git a/Message/Http/OSType.php b/Message/Http/OSType.php index 3c5c76f66..6e7bb3bbd 100644 --- a/Message/Http/OSType.php +++ b/Message/Http/OSType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Http; diff --git a/Message/Http/Request.php b/Message/Http/Request.php index 53eb4408e..9b03f30be 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Http; @@ -148,7 +148,7 @@ class Request extends RequestAbstract */ private function loadRequestLanguage() : string { - if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { return 'EN'; } @@ -185,7 +185,7 @@ class Request extends RequestAbstract UriFactory::setQuery('/lang', $this->header->getL11n()->getLanguage()); // todo: flush previous - foreach($this->data as $key => $value) { + foreach ($this->data as $key => $value) { UriFactory::setQuery('?' . $key, $value); } } diff --git a/Message/Http/RequestMethod.php b/Message/Http/RequestMethod.php index d68d133cf..f7d5f6d61 100644 --- a/Message/Http/RequestMethod.php +++ b/Message/Http/RequestMethod.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Http; @@ -28,10 +28,10 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class RequestMethod extends Enum { - /* public */ const GET = 'GET'; /* GET */ - /* public */ const POST = 'POST'; /* POST */ - /* public */ const PUT = 'PUT'; /* PUT */ - /* public */ const DELETE = 'DELETE'; /* DELETE */ - /* public */ const HEAD = 'HEAD'; /* HEAD */ - /* public */ const TRACE = 'TRACE'; /* TRACE */ + /* public */ const GET = 'GET'; /* GET */ + /* public */ const POST = 'POST'; /* POST */ + /* public */ const PUT = 'PUT'; /* PUT */ + /* public */ const DELETE = 'DELETE'; /* DELETE */ + /* public */ const HEAD = 'HEAD'; /* HEAD */ + /* public */ const TRACE = 'TRACE'; /* TRACE */ } diff --git a/Message/Http/RequestStatus.php b/Message/Http/RequestStatus.php index 0a573911a..63a9fc562 100644 --- a/Message/Http/RequestStatus.php +++ b/Message/Http/RequestStatus.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Http; diff --git a/Message/Http/RequestStatusCode.php b/Message/Http/RequestStatusCode.php index 2d45d292c..c35bc72b0 100644 --- a/Message/Http/RequestStatusCode.php +++ b/Message/Http/RequestStatusCode.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Http; use phpOMS\Stdlib\Base\Enum; diff --git a/Message/Http/Response.php b/Message/Http/Response.php index 0b8a5020a..4eccd8cb4 100644 --- a/Message/Http/Response.php +++ b/Message/Http/Response.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Http; @@ -106,8 +106,8 @@ class Response extends ResponseAbstract implements RenderableInterface { $types = $this->header->get('Content-Type'); - foreach($types as $type) { - if(stripos($type, MimeType::M_JSON) !== false) { + foreach ($types as $type) { + if (stripos($type, MimeType::M_JSON) !== false) { return $this->jsonSerialize(); } } @@ -141,6 +141,12 @@ class Response extends ResponseAbstract implements RenderableInterface } } + $types = $this->header->get('Content-Type'); + + if (stripos($types[0], MimeType::M_HTML) !== false) { + return trim(preg_replace('/(\s{2,}|\n|\t)(?![^<>]*<\/pre>)/', ' ', $render)); + } + return $render; } diff --git a/Message/Http/Rest.php b/Message/Http/Rest.php index 9feff40d1..ebdd8f2a3 100644 --- a/Message/Http/Rest.php +++ b/Message/Http/Rest.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Http; diff --git a/Message/Mail/EmailAbstract.php b/Message/Mail/EmailAbstract.php index 7ec52fb59..93fc94ee8 100644 --- a/Message/Mail/EmailAbstract.php +++ b/Message/Mail/EmailAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Mail; @@ -127,7 +127,7 @@ class EmailAbstract */ public function disconnect() { - if(!isset($this->con)) { + if (!isset($this->con)) { imap_close($this->con); $this->con = null; } @@ -148,7 +148,7 @@ class EmailAbstract $this->mailbox = substr($this->mailbox, 0, -1) . ($this->ssl ? '/ssl/validate-cert' : '/novalidate-cert') . '}'; // /novalidate-cert - if(!isset($this->con)) { + if (!isset($this->con)) { $this->con = imap_open($this->mailbox . 'INBOX', $user, $pass); } } @@ -489,7 +489,7 @@ class EmailAbstract */ public function getMessageOverview(int $length = 0, int $start = 1) : array { - if($length === 0) { + if ($length === 0) { $info = imap_check($this->con); $length = $info->Nmsgs; } diff --git a/Message/Mail/Imap.php b/Message/Mail/Imap.php index 4e19db672..82386a536 100644 --- a/Message/Mail/Imap.php +++ b/Message/Mail/Imap.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Mail; diff --git a/Message/Mail/Mail.php b/Message/Mail/Mail.php index bc52fb4c5..5e2b5a692 100644 --- a/Message/Mail/Mail.php +++ b/Message/Mail/Mail.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Mail; diff --git a/Message/Mail/Nntp.php b/Message/Mail/Nntp.php index a0a905d23..00288ccb1 100644 --- a/Message/Mail/Nntp.php +++ b/Message/Mail/Nntp.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Mail; diff --git a/Message/Mail/Pop3.php b/Message/Mail/Pop3.php index 38830a32d..73194dc50 100644 --- a/Message/Mail/Pop3.php +++ b/Message/Mail/Pop3.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Mail; diff --git a/Message/MessageInterface.php b/Message/MessageInterface.php index 071b36133..26b44b901 100644 --- a/Message/MessageInterface.php +++ b/Message/MessageInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message; diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index 8c2edfff5..2197b9862 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -11,12 +11,11 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message; use phpOMS\Stdlib\Base\Exception\InvalidEnumValue; -use phpOMS\Localization\Localization; use phpOMS\Uri\UriInterface; /** @@ -75,7 +74,7 @@ abstract class RequestAbstract implements MessageInterface /** * Request type. * - * @var \phpOMS\Message\RequestSource + * @var int * @since 1.0.0 */ protected $source = RequestSource::UNDEFINED; @@ -205,7 +204,7 @@ abstract class RequestAbstract implements MessageInterface */ public function getData($key = null) { - if(!isset($key)) { + if (!isset($key)) { return $this->data; } @@ -266,7 +265,7 @@ abstract class RequestAbstract implements MessageInterface /** * {@inheritdoc} */ - public abstract function getOrigin() : string; + abstract public function getOrigin() : string; /** * {@inheritdoc} diff --git a/Message/RequestSource.php b/Message/RequestSource.php index 3b30da6df..e3d7c1051 100644 --- a/Message/RequestSource.php +++ b/Message/RequestSource.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message; diff --git a/Message/ResponseAbstract.php b/Message/ResponseAbstract.php index a721adc5b..05caf91b1 100644 --- a/Message/ResponseAbstract.php +++ b/Message/ResponseAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message; diff --git a/Message/ResponseType.php b/Message/ResponseType.php index 5681897b8..af85a9a89 100644 --- a/Message/ResponseType.php +++ b/Message/ResponseType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message; diff --git a/Message/Socket/Request.php b/Message/Socket/Request.php index e44169e2b..81399aa45 100644 --- a/Message/Socket/Request.php +++ b/Message/Socket/Request.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Socket; class Request diff --git a/Message/Socket/Response.php b/Message/Socket/Response.php index df4a9bfcd..51c59782f 100644 --- a/Message/Socket/Response.php +++ b/Message/Socket/Response.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message\Socket; class Response diff --git a/Message/UploadedFileInterface.php b/Message/UploadedFileInterface.php index 2ab08acb7..d0966c51d 100644 --- a/Message/UploadedFileInterface.php +++ b/Message/UploadedFileInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Message; diff --git a/Model/Html/Head.php b/Model/Html/Head.php index 250d10f80..f49e49399 100644 --- a/Model/Html/Head.php +++ b/Model/Html/Head.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Model\Html; diff --git a/Model/Html/Meta.php b/Model/Html/Meta.php index 1725be601..f1700b0c6 100644 --- a/Model/Html/Meta.php +++ b/Model/Html/Meta.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Model\Html; diff --git a/Module/ActivateAbstract.php b/Module/ActivateAbstract.php index 91957ea00..ddebdc2f5 100644 --- a/Module/ActivateAbstract.php +++ b/Module/ActivateAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; diff --git a/Module/ConsoleInterface.php b/Module/ConsoleInterface.php index e84fad460..9a1c4bd52 100644 --- a/Module/ConsoleInterface.php +++ b/Module/ConsoleInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; diff --git a/Module/DeactivateAbstract.php b/Module/DeactivateAbstract.php index 1e3f3b763..fdab8e29b 100644 --- a/Module/DeactivateAbstract.php +++ b/Module/DeactivateAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; diff --git a/Module/Exception/InvalidModuleException.php b/Module/Exception/InvalidModuleException.php index 0ffdab349..c72d6d7a7 100644 --- a/Module/Exception/InvalidModuleException.php +++ b/Module/Exception/InvalidModuleException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module\Exception; @@ -31,7 +31,7 @@ class InvalidModuleException extends \UnexpectedValueException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/Module/Exception/InvalidThemeException.php b/Module/Exception/InvalidThemeException.php index bfe872281..66558b7db 100644 --- a/Module/Exception/InvalidThemeException.php +++ b/Module/Exception/InvalidThemeException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module\Exception; @@ -31,7 +31,7 @@ class InvalidThemeException extends \UnexpectedValueException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/Module/InfoManager.php b/Module/InfoManager.php index 70c5bcda8..1bc973213 100644 --- a/Module/InfoManager.php +++ b/Module/InfoManager.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; @@ -99,7 +99,7 @@ class InfoManager */ public function update() /* : void */ { - if (!file_exists($this->path)) { + if (!file_exists($this->path)) { throw new PathException((string) $this->path); } diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index 8dbf6e88b..81c5ed3ce 100644 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; diff --git a/Module/ModuleAbstract.php b/Module/ModuleAbstract.php index 8e4aa87dc..c35ca7df9 100644 --- a/Module/ModuleAbstract.php +++ b/Module/ModuleAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; @@ -76,7 +76,7 @@ abstract class ModuleAbstract /** * Dependencies. * - * @var string + * @var string[] * @since 1.0.0 */ protected static $dependencies = []; diff --git a/Module/ModuleFactory.php b/Module/ModuleFactory.php index 338d2852d..77d23a67e 100644 --- a/Module/ModuleFactory.php +++ b/Module/ModuleFactory.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; @@ -75,7 +75,7 @@ class ModuleFactory $class = '\\Modules\\' . $module . '\\Controller'; if (!isset(self::$loaded[$module])) { - if(Autoloader::exists($class) !== false) { + if (Autoloader::exists($class) !== false) { try { $obj = new $class($app); self::$loaded[$module] = $obj; diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 9f605b25b..ec2e10f36 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; @@ -419,13 +419,13 @@ class ModuleManager public function reInit(string $module) : bool { $info = $this->loadInfo($module); - /** @var $class InstallerAbstract */ $class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer'; if (!Autoloader::exists($class)) { throw new InvalidModuleException($info->getDirectory()); } + /** @var $class InstallerAbstract */ $class::reInit($this->modulePath, $info); } @@ -511,13 +511,13 @@ class ModuleManager */ private function installModule(InfoManager $info) /* : void */ { - /** @var $class InstallerAbstract */ $class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer'; if (!Autoloader::exists($class)) { throw new InvalidModuleException($info->getDirectory()); } + /** @var $class InstallerAbstract */ $class::install($this->modulePath, $this->app->dbPool, $info); } @@ -626,7 +626,7 @@ class ModuleManager { $toInit = $this->getRoutedModules($request); - foreach($toInit as $module) { + foreach ($toInit as $module) { $this->initModuleController($module); } } diff --git a/Module/NullModule.php b/Module/NullModule.php index 54a919db3..78ac1e699 100644 --- a/Module/NullModule.php +++ b/Module/NullModule.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; diff --git a/Module/PackageManager.php b/Module/PackageManager.php index d743e1fcf..8405d642b 100644 --- a/Module/PackageManager.php +++ b/Module/PackageManager.php @@ -11,12 +11,11 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; use phpOMS\System\File\PathException; -use phpOMS\Utils\ArrayUtils; use phpOMS\System\File\Local\File; use phpOMS\System\File\Local\Directory; use phpOMS\System\File\Local\LocalStorage; @@ -71,7 +70,7 @@ class PackageManager * Constructor. * * @param string $path Package source path e.g. path after download. - * @param string basePath Path of the application + * @param string $basePath Path of the application * * @since 1.0.0 */ @@ -86,11 +85,11 @@ class PackageManager * * @param string $path Temporary extract path * - * @return bool - * + * @return void + * * @since 1.0.0 */ - public function extract(string $path) : bool + public function extract(string $path) /* : void */ { $this->extractPath = $path; Zip::unpack($this->path, $this->extractPath); @@ -107,7 +106,7 @@ class PackageManager */ public function load() /* : void */ { - if(!file_exists($this->extractPath)) { + if (!file_exists($this->extractPath)) { throw new PathException($this->extractPath); } @@ -140,8 +139,8 @@ class PackageManager $files = Directory::list($this->extractPath . '/package'); $state = \sodium_crypto_generichash_init(); - foreach($files as $file) { - if($file === 'package.cert') { + foreach ($files as $file) { + if ($file === 'package.cert') { continue; } @@ -160,12 +159,12 @@ class PackageManager */ public function install() /* : void */ { - if(!$this->isValid()) { + if (!$this->isValid()) { throw new \Exception(); } - foreach($this->info as $key => $components) { - if(function_exists($this->{$key})) { + foreach ($this->info as $key => $components) { + if (function_exists($this->{$key})) { $this->{$key}($components); } } @@ -180,7 +179,7 @@ class PackageManager */ private function move($components) { - foreach($components as $component) { + foreach ($components as $component) { LocalStorage::move($this->basePath . '/' . $component['from'], $this->basePath . '/' . $component['to'], true); } } @@ -194,8 +193,8 @@ class PackageManager */ private function copy($components) { - foreach($components as $component) { - if(StringUtils::startsWith($component['from'], 'Package/')) { + foreach ($components as $component) { + if (StringUtils::startsWith($component['from'], 'Package/')) { LocalStorage::copy($this->path . '/' . $component['from'], $this->basePath . '/' . $component['to'], true); } else { LocalStorage::copy($this->basePath . '/' . $component['from'], $this->basePath . '/' . $component['to'], true); @@ -212,7 +211,7 @@ class PackageManager */ private function delete($components) { - foreach($components as $component) { + foreach ($components as $component) { LocalStorage::delete($this->basePath . '/' . $component); } } @@ -226,7 +225,7 @@ class PackageManager */ private function execute($components) { - foreach($components as $component) { + foreach ($components as $component) { include $this->basePath . '/' . $component; } } diff --git a/Module/SocketInterface.php b/Module/SocketInterface.php index 7a81858a2..a82d17b5e 100644 --- a/Module/SocketInterface.php +++ b/Module/SocketInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; diff --git a/Module/UninstallAbstract.php b/Module/UninstallAbstract.php index 8bce9306f..4a1c7d52c 100644 --- a/Module/UninstallAbstract.php +++ b/Module/UninstallAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; diff --git a/Module/UpdateAbstract.php b/Module/UpdateAbstract.php index 2bc826f9f..af8b503f3 100644 --- a/Module/UpdateAbstract.php +++ b/Module/UpdateAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; diff --git a/Module/WebInterface.php b/Module/WebInterface.php index f1e95509f..6f1b3726a 100644 --- a/Module/WebInterface.php +++ b/Module/WebInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Module; diff --git a/Pattern/Mediator.php b/Pattern/Mediator.php index 97eda8ce4..261fa5550 100644 --- a/Pattern/Mediator.php +++ b/Pattern/Mediator.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Pattern; diff --git a/Pattern/Multition.php b/Pattern/Multition.php index d575ebf5d..19924a69e 100644 --- a/Pattern/Multition.php +++ b/Pattern/Multition.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Pattern; diff --git a/Pattern/Observer.php b/Pattern/Observer.php index cb32fd7fb..538328aa0 100644 --- a/Pattern/Observer.php +++ b/Pattern/Observer.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Pattern; diff --git a/Pattern/Singleton.php b/Pattern/Singleton.php index 72f7f6e21..861f143b7 100644 --- a/Pattern/Singleton.php +++ b/Pattern/Singleton.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Pattern; diff --git a/Pattern/Subject.php b/Pattern/Subject.php index 31641d3b7..e74cc568e 100644 --- a/Pattern/Subject.php +++ b/Pattern/Subject.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Pattern; diff --git a/Router/RouteVerb.php b/Router/RouteVerb.php index 4c36d6732..611835779 100644 --- a/Router/RouteVerb.php +++ b/Router/RouteVerb.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Router; diff --git a/Router/Router.php b/Router/Router.php index 7624fdf9c..4d47301d2 100644 --- a/Router/Router.php +++ b/Router/Router.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Router; @@ -96,7 +96,7 @@ class Router * @param string|RequestAbstract $request Request to route * @param int $verb Route verb * - * @return string[] + * @return array[] * * @throws \InvalidArgumentException * diff --git a/Security/Encryption/Encryption.php b/Security/Encryption/Encryption.php index 16cdd1ff4..defd40f1a 100644 --- a/Security/Encryption/Encryption.php +++ b/Security/Encryption/Encryption.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Security\Encryption; diff --git a/Socket/Client/Client.php b/Socket/Client/Client.php index fcd2b9d1f..44ecb23c4 100644 --- a/Socket/Client/Client.php +++ b/Socket/Client/Client.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket\Client; @@ -80,7 +80,7 @@ class Client extends SocketAbstract $read = [$this->sock]; - //if(socket_select($read, $write = null, $except = null, 0) < 1) { + //if (socket_select($read, $write = null, $except = null, 0) < 1) { // error // socket_last_error(); // socket_strerror(socket_last_error()); diff --git a/Socket/Client/ClientConnection.php b/Socket/Client/ClientConnection.php index 8897cbf68..0bff3ff47 100644 --- a/Socket/Client/ClientConnection.php +++ b/Socket/Client/ClientConnection.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket\Client; diff --git a/Socket/Client/NullClientConnection.php b/Socket/Client/NullClientConnection.php index 531405d99..a0bcf705e 100644 --- a/Socket/Client/NullClientConnection.php +++ b/Socket/Client/NullClientConnection.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket\Client; diff --git a/Socket/CommandManager.php b/Socket/CommandManager.php index 3d3462358..ba0cb9dd2 100644 --- a/Socket/CommandManager.php +++ b/Socket/CommandManager.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket; diff --git a/Socket/Packets/Header.php b/Socket/Packets/Header.php index 2e28616e8..0dbdca45d 100644 --- a/Socket/Packets/Header.php +++ b/Socket/Packets/Header.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket\Packets; diff --git a/Socket/Packets/PacketAbstract.php b/Socket/Packets/PacketAbstract.php index 8a9455db2..e289ede2c 100644 --- a/Socket/Packets/PacketAbstract.php +++ b/Socket/Packets/PacketAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket\Packets; diff --git a/Socket/Packets/PacketManager.php b/Socket/Packets/PacketManager.php index 4753c2684..7a3d6f456 100644 --- a/Socket/Packets/PacketManager.php +++ b/Socket/Packets/PacketManager.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket\Packets; diff --git a/Socket/Packets/PacketType.php b/Socket/Packets/PacketType.php index 62011fde1..761f7c8c2 100644 --- a/Socket/Packets/PacketType.php +++ b/Socket/Packets/PacketType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket\Packets; diff --git a/Socket/Server/ClientManager.php b/Socket/Server/ClientManager.php index 4b1f2a732..d6ee215e4 100644 --- a/Socket/Server/ClientManager.php +++ b/Socket/Server/ClientManager.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket\Server; diff --git a/Socket/Server/Server.php b/Socket/Server/Server.php index eacdcdd9c..047a94509 100644 --- a/Socket/Server/Server.php +++ b/Socket/Server/Server.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket\Server; diff --git a/Socket/SocketAbstract.php b/Socket/SocketAbstract.php index 973b495a7..213b2d6b2 100644 --- a/Socket/SocketAbstract.php +++ b/Socket/SocketAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket; diff --git a/Socket/SocketInterface.php b/Socket/SocketInterface.php index 1640a5329..6bc8ee629 100644 --- a/Socket/SocketInterface.php +++ b/Socket/SocketInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket; diff --git a/Socket/SocketType.php b/Socket/SocketType.php index 94008f57d..8d3b689df 100644 --- a/Socket/SocketType.php +++ b/Socket/SocketType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Socket; diff --git a/Stdlib/Base/Address.php b/Stdlib/Base/Address.php index 58192c2d4..6b2d125f1 100644 --- a/Stdlib/Base/Address.php +++ b/Stdlib/Base/Address.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base; diff --git a/Stdlib/Base/AddressType.php b/Stdlib/Base/AddressType.php index f33b460ba..81f68fe46 100644 --- a/Stdlib/Base/AddressType.php +++ b/Stdlib/Base/AddressType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base; diff --git a/Stdlib/Base/Enum.php b/Stdlib/Base/Enum.php index abaaed0d1..357252dc6 100644 --- a/Stdlib/Base/Enum.php +++ b/Stdlib/Base/Enum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base; diff --git a/Stdlib/Base/EnumArray.php b/Stdlib/Base/EnumArray.php index 76637b2c9..419c3a5a2 100644 --- a/Stdlib/Base/EnumArray.php +++ b/Stdlib/Base/EnumArray.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base; diff --git a/Stdlib/Base/ExactFloat.php b/Stdlib/Base/ExactFloat.php index 07f1cfc0e..d59902285 100644 --- a/Stdlib/Base/ExactFloat.php +++ b/Stdlib/Base/ExactFloat.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base; diff --git a/Stdlib/Base/Exception/InvalidEnumName.php b/Stdlib/Base/Exception/InvalidEnumName.php index a15dfa205..9d114b39b 100644 --- a/Stdlib/Base/Exception/InvalidEnumName.php +++ b/Stdlib/Base/Exception/InvalidEnumName.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base\Exception; @@ -34,7 +34,7 @@ class InvalidEnumName extends \UnexpectedValueException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/Stdlib/Base/Exception/InvalidEnumValue.php b/Stdlib/Base/Exception/InvalidEnumValue.php index fb2a8ef2f..446ae23ac 100644 --- a/Stdlib/Base/Exception/InvalidEnumValue.php +++ b/Stdlib/Base/Exception/InvalidEnumValue.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base\Exception; @@ -34,7 +34,7 @@ class InvalidEnumValue extends \UnexpectedValueException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/Stdlib/Base/Iban.php b/Stdlib/Base/Iban.php index 917cece85..4cdb10f6a 100644 --- a/Stdlib/Base/Iban.php +++ b/Stdlib/Base/Iban.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base; diff --git a/Stdlib/Base/Location.php b/Stdlib/Base/Location.php index c26de4f17..a348b9862 100644 --- a/Stdlib/Base/Location.php +++ b/Stdlib/Base/Location.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base; diff --git a/Stdlib/Base/NullLocation.php b/Stdlib/Base/NullLocation.php index 060c35d83..6cd8cf87f 100644 --- a/Stdlib/Base/NullLocation.php +++ b/Stdlib/Base/NullLocation.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base; diff --git a/Stdlib/Base/PhoneType.php b/Stdlib/Base/PhoneType.php index f099ce37a..dbcf64f74 100644 --- a/Stdlib/Base/PhoneType.php +++ b/Stdlib/Base/PhoneType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base; diff --git a/Stdlib/Base/SmartDateTime.php b/Stdlib/Base/SmartDateTime.php index bcba717e2..28962eec0 100644 --- a/Stdlib/Base/SmartDateTime.php +++ b/Stdlib/Base/SmartDateTime.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Base; @@ -281,20 +281,20 @@ class SmartDateTime extends \DateTime $daysPreviousMonth = $previousMonth->getDaysOfMonth(); // add difference to $weekStartsWith counting backwards from days of previous month (reorder so that lowest value first) - for($i = $daysPreviousMonth - $diffToWeekStart; $i < $daysPreviousMonth; $i++) { - $days[] = new \DateTime($previousMonth->format('Y') . '-' . $previousMonth->format('m') . '-' . ($i+1)); + for ($i = $daysPreviousMonth - $diffToWeekStart; $i < $daysPreviousMonth; $i++) { + $days[] = new \DateTime($previousMonth->format('Y') . '-' . $previousMonth->format('m') . '-' . ($i + 1)); } // add normal count of current days $daysMonth = $this->getDaysOfMonth(); - for($i = 1; $i <= $daysMonth; $i++) { + for ($i = 1; $i <= $daysMonth; $i++) { $days[] = new \DateTime($this->format('Y') . '-' . $this->format('m') . '-' . ($i)); } // add remaining days to next month (7*6 - difference+count of current month) $remainingDays = 42 - $diffToWeekStart - $daysMonth; $nextMonth = $this->createModify(0, 1); - for($i = 1; $i <= $remainingDays; $i++) { + for ($i = 1; $i <= $remainingDays; $i++) { $days[] = new \DateTime($nextMonth->format('Y') . '-' . $nextMonth->format('m') . '-' . ($i)); } diff --git a/Stdlib/Collection/Collection.php b/Stdlib/Collection/Collection.php index d5b23ab53..c0ceed2f0 100644 --- a/Stdlib/Collection/Collection.php +++ b/Stdlib/Collection/Collection.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Collection; @@ -148,7 +148,7 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab $arrays = array_chunk($this->collection, $size); $collections = []; - foreach($arrays as $array) { + foreach ($arrays as $array) { $collections[] = new self($array); } @@ -622,7 +622,7 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab */ public function offsetGet($offset) { - if(!isset($this->collection[$offset])) { + if (!isset($this->collection[$offset])) { throw new \Exception('Invalid offset'); } @@ -719,7 +719,7 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab */ public function offsetUnset($offset) { - if(isset($this->collection[$offset])) { + if (isset($this->collection[$offset])) { unset($this->collection[$offset]); } } diff --git a/Stdlib/Graph/BinaryTree.php b/Stdlib/Graph/BinaryTree.php index bd8f5f233..cc6a2baad 100644 --- a/Stdlib/Graph/BinaryTree.php +++ b/Stdlib/Graph/BinaryTree.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Graph; @@ -28,98 +28,98 @@ namespace phpOMS\Stdlib\Graph; */ class BinaryTree extends Tree { - public static function invert($list) : BinaryTree - { - if (empty($list->getNodes())) { - return $list; - } + public static function invert($list) : BinaryTree + { + if (empty($list->getNodes())) { + return $list; + } - $left = $list->getLeft(); - $list->setLeft($list->invert($list->nodes[1])); - $list->setRight($list->invert($left)); + $left = $list->getLeft(); + $list->setLeft($list->invert($list->nodes[1])); + $list->setRight($list->invert($left)); - return $list; - } + return $list; + } - /** + /** * Get left node of a node. * * @param Node $base Tree node - * - * @return Node Left node + * + * @return Node Left node * * @since 1.0.0 */ - public function getLeft(Node $base) - { - $neighbors = $base->getNeighbors($base); + public function getLeft(Node $base) + { + $neighbors = $base->getNeighbors($base); - // todo: index can be wrong, see setLeft/setRight - return $neighbors[0] ?? null; - } + // todo: index can be wrong, see setLeft/setRight + return $neighbors[0] ?? null; + } - /** + /** * Get right node of a node. * * @param Node $base Tree node - * - * @return Node Right node + * + * @return Node Right node * * @since 1.0.0 */ - public function getRight(Node $base) - { - $neighbors = $this->getNeighbors($base); + public function getRight(Node $base) + { + $neighbors = $this->getNeighbors($base); - // todo: index can be wrong, see setLeft/setRight - return $neighbors[1] ?? null; - } + // todo: index can be wrong, see setLeft/setRight + return $neighbors[1] ?? null; + } - /** + /** * Set left node of node. * * @param Node $base Base node * @param Node $left Left node - * - * @return BinaryTree + * + * @return BinaryTree * * @since 1.0.0 */ - public function setLeft(Node $base, Node $left) : BinaryTree - { - if($this->getLeft($base) === null) { - $this->addNodeRelative($base, $left); - // todo: doesn't know that this is left - // todo: maybe need to add numerics to edges? - } else { - // todo: replace node - } + public function setLeft(Node $base, Node $left) : BinaryTree + { + if ($this->getLeft($base) === null) { + $this->addNodeRelative($base, $left); + // todo: doesn't know that this is left + // todo: maybe need to add numerics to edges? + } else { + // todo: replace node + } - return $this; - } + return $this; + } - /** + /** * Set right node of node. * * @param Node $base Base node * @param Node $right Right node - * - * @return BinaryTree + * + * @return BinaryTree * * @since 1.0.0 */ - public function setRight(Node $base, Node $right) /* : void */ - { - if($this->getRight($base) === null) { - $this->addNodeRelative($base, $right); - // todo: doesn't know that this is right - // todo: maybe need to add numerics to edges? - } else { - // todo: replace node - } - } + public function setRight(Node $base, Node $right) /* : void */ + { + if ($this->getRight($base) === null) { + $this->addNodeRelative($base, $right); + // todo: doesn't know that this is right + // todo: maybe need to add numerics to edges? + } else { + // todo: replace node + } + } - /** + /** * Perform action on tree in in-order. * * @param Node $node Tree node @@ -127,42 +127,42 @@ class BinaryTree extends Tree * * @since 1.0.0 */ - public function inOrder(Node $node, \Closure $callback) - { - $this->inOrder($this->getLeft($node), $callback); - $callback($node); - $this->inOrder($this->getRight($node), $callback); - } + public function inOrder(Node $node, \Closure $callback) + { + $this->inOrder($this->getLeft($node), $callback); + $callback($node); + $this->inOrder($this->getRight($node), $callback); + } - /** + /** * Get nodes in vertical order. * * @param Node $node Tree node * @param int $horizontalDistance Horizontal distance - * @param Node[] &$order Ordered nodes by horizontal distance + * @param Node[] &$order Ordered nodes by horizontal distance * * @since 1.0.0 */ - private function getVerticalOrder(Node $node, int $horizontalDistance = 0, array &$order) - { - if(!isset($order[$horizontalDistance])) { - $order[$horizontalDistance] = []; - } + private function getVerticalOrder(Node $node, int $horizontalDistance = 0, array &$order) + { + if (!isset($order[$horizontalDistance])) { + $order[$horizontalDistance] = []; + } - $order[$horizontalDistance][] = $node; - $left = $this->getLeft($node); - $right = $this->getRight($node); + $order[$horizontalDistance][] = $node; + $left = $this->getLeft($node); + $right = $this->getRight($node); - if(isset($left)) { - $this->getVerticalOrder($left, $horizontalDistance-1, $order); - } + if (isset($left)) { + $this->getVerticalOrder($left, $horizontalDistance - 1, $order); + } - if(isset($right)) { - $this->getVerticalOrder($right, $horizontalDistance+1, $order); - } - } + if (isset($right)) { + $this->getVerticalOrder($right, $horizontalDistance + 1, $order); + } + } - /** + /** * Perform action on tree in vertical-order. * * @param Node $node Tree node @@ -170,45 +170,45 @@ class BinaryTree extends Tree * * @since 1.0.0 */ - public function verticalOrder(Node $node, \Closure $callback) - { - $order = []; - $this->getVerticalOrder($node, 0, $order); + public function verticalOrder(Node $node, \Closure $callback) + { + $order = []; + $this->getVerticalOrder($node, 0, $order); - foreach($order as $level) { - foreach($level as $node) { - $callback($node); - } - } - } + foreach ($order as $level) { + foreach ($level as $node) { + $callback($node); + } + } + } - /** + /** * Check if tree is symmetric. * * @param Node $node1 Tree node1 * @param Node $node2 Tree node2 (optional, can be different tree) - * - * @return bool True if tree is symmetric, false if tree is not symmetric + * + * @return bool True if tree is symmetric, false if tree is not symmetric * * @since 1.0.0 */ - public function isSymmetric(Node $node1 = null, Node $node2 = null) : bool - { - if(!isset($node1) && !isset($node2)) { - return true; - } + public function isSymmetric(Node $node1 = null, Node $node2 = null) : bool + { + if (!isset($node1) && !isset($node2)) { + return true; + } - $left1 = $this->getLeft($node1); - $right1 = $this->getRight($node1); + $left1 = $this->getLeft($node1); + $right1 = $this->getRight($node1); - $left2 = isset($node2) ? $this->getLeft($node1) : $this->getLeft($node2); - $right2 = isset($node2) ? $this->getRight($node1) : $this->getRight($node2); + $left2 = isset($node2) ? $this->getLeft($node1) : $this->getLeft($node2); + $right2 = isset($node2) ? $this->getRight($node1) : $this->getRight($node2); - // todo: compare values? true symmetry requires the values to be the same - if(isset($node1, $node2)) { - return $this->isSymmetric($left1, $right2) && $this->isSymmetric($right1, $left2); - } + // todo: compare values? true symmetry requires the values to be the same + if (isset($node1, $node2)) { + return $this->isSymmetric($left1, $right2) && $this->isSymmetric($right1, $left2); + } - return false; - } + return false; + } } \ No newline at end of file diff --git a/Stdlib/Graph/Edge.php b/Stdlib/Graph/Edge.php index 3ce06ca2d..3310a2b93 100644 --- a/Stdlib/Graph/Edge.php +++ b/Stdlib/Graph/Edge.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Graph; diff --git a/Stdlib/Graph/Graph.php b/Stdlib/Graph/Graph.php index 78fbddada..27816c629 100644 --- a/Stdlib/Graph/Graph.php +++ b/Stdlib/Graph/Graph.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Graph; diff --git a/Stdlib/Graph/Node.php b/Stdlib/Graph/Node.php index 507b2caa3..fad1b5127 100644 --- a/Stdlib/Graph/Node.php +++ b/Stdlib/Graph/Node.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Graph; diff --git a/Stdlib/Graph/Tree.php b/Stdlib/Graph/Tree.php index 7c6a439af..7e8e8cb59 100644 --- a/Stdlib/Graph/Tree.php +++ b/Stdlib/Graph/Tree.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Graph; @@ -26,26 +26,26 @@ namespace phpOMS\Stdlib\Graph; */ class Tree extends Graph { - /** + /** * Root node. * * @var Node * @since 1.0.0 */ - private $root = null; + private $root = null; - /** + /** * Constructor. * * @since 1.0.0 */ - public function __construct() - { - $root = new Node(); - parent::addNode($root); - } + public function __construct() + { + $root = new Node(); + parent::addNode($root); + } - /** + /** * Add a note relative to a node. * * @param Node $base Base node @@ -55,15 +55,15 @@ class Tree extends Graph * * @since 1.0.0 */ - public function addRelativeNode(Node $base, Node $node) : Tree - { - parent::addNode($node); - parent::addEdge(new Edge($base, $node)); + public function addRelativeNode(Node $base, Node $node) : Tree + { + parent::addNode($node); + parent::addEdge(new Edge($base, $node)); - return $this; - } + return $this; + } - /** + /** * Get maximum tree depth. * * @param Node $node Tree node @@ -72,25 +72,25 @@ class Tree extends Graph * * @since 1.0.0 */ - public function getMaxDepth(Node $node = null) : int - { - $currentNode = $node ?? $this->root; + public function getMaxDepth(Node $node = null) : int + { + $currentNode = $node ?? $this->root; - if(!isset($currentNode)) { - return 0; - } + if (!isset($currentNode)) { + return 0; + } - $depth = 1; - $neighbors = $this->getNeighbors($currentNode); + $depth = 1; + $neighbors = $this->getNeighbors($currentNode); - foreach($neighbors as $neighbor) { - $depth = max($depth, $depth + $this->getMaxDepth($neighbor)); - } + foreach ($neighbors as $neighbor) { + $depth = max($depth, $depth + $this->getMaxDepth($neighbor)); + } - return $depth; - } + return $depth; + } - /** + /** * Get minimum tree path. * * @param Node $node Tree node @@ -99,27 +99,27 @@ class Tree extends Graph * * @since 1.0.0 */ - public function getMinDepth(Node $node = null) : int - { - $currentNode = $node ?? $this->root; + public function getMinDepth(Node $node = null) : int + { + $currentNode = $node ?? $this->root; - if(!isset($currentNode)) { - return 0; - } + if (!isset($currentNode)) { + return 0; + } - $depth = []; - $neighbors = $this->getNeighbors($currentNode); + $depth = []; + $neighbors = $this->getNeighbors($currentNode); - foreach($neighbors as $neighbor) { - $depth[] = $this->getMaxDepth($neighbor); - } + foreach ($neighbors as $neighbor) { + $depth[] = $this->getMaxDepth($neighbor); + } - $depth = empty($depth) ? 0 : $depth; + $depth = empty($depth) ? 0 : $depth; - return min($depth) + 1; - } + return min($depth) + 1; + } - /** + /** * Perform task on tree nodes in level order. * * @param Node $node Tree node @@ -129,17 +129,17 @@ class Tree extends Graph * * @since 1.0.0 */ - public function levelOrder(Node $node, \Closure $callback) - { - $depth = $this->getMaxDepth(); + public function levelOrder(Node $node, \Closure $callback) + { + $depth = $this->getMaxDepth(); - for($i = 1; $i < $depth; $i++) { - $nodes = $this->getLevel($i); - callback($nodes); - } - } + for ($i = 1; $i < $depth; $i++) { + $nodes = $this->getLevel($i); + callback($nodes); + } + } - /** + /** * Check if node is leaf. * * @param Node $node Tree node @@ -148,12 +148,12 @@ class Tree extends Graph * * @since 1.0.0 */ - public function isLeaf(Node $node) : bool - { - return count($this->getEdgesOfNode($node)) === 1; - } + public function isLeaf(Node $node) : bool + { + return count($this->getEdgesOfNode($node)) === 1; + } - /** + /** * Get all nodes of a specific level. * * @param int $level Level to retrieve @@ -163,24 +163,24 @@ class Tree extends Graph * * @since 1.0.0 */ - public function getLevelNodes(int $level, Node $node) : array - { - --$level; - $neighbors = $this->getNeighbors($node); - $nodes = []; + public function getLevelNodes(int $level, Node $node) : array + { + --$level; + $neighbors = $this->getNeighbors($node); + $nodes = []; - if($level === 1) { - return $neighbors; - } + if ($level === 1) { + return $neighbors; + } - foreach($neighbors as $neighbor) { - array_merge($nodes, $this->getLevelNodes($level, $neighbor)); - } + foreach ($neighbors as $neighbor) { + array_merge($nodes, $this->getLevelNodes($level, $neighbor)); + } - return $nodes; - } + return $nodes; + } - /** + /** * Check if the tree is full. * * @param int $type Child nodes per non-leaf node @@ -189,24 +189,24 @@ class Tree extends Graph * * @since 1.0.0 */ - public function isFull(int $type) : bool - { - if(count($this->edges) % $type !== 0) { - return false; - } + public function isFull(int $type) : bool + { + if (count($this->edges) % $type !== 0) { + return false; + } - foreach($this->nodes as $node) { - $neighbors = count($this->getNeighbors($node)); + foreach ($this->nodes as $node) { + $neighbors = count($this->getNeighbors($node)); - if($neighbors !== $type && $neighbors !== 0) { - return false; - } - } + if ($neighbors !== $type && $neighbors !== 0) { + return false; + } + } - return true; - } + return true; + } - /** + /** * Perform action on tree in pre-order. * * @param Node $node Tree node @@ -214,21 +214,21 @@ class Tree extends Graph * * @since 1.0.0 */ - public function preOrder(Node $node, \Closure $callback) { - if(count($this->nodes) === 0) { - return; - } + public function preOrder(Node $node, \Closure $callback) { + if (count($this->nodes) === 0) { + return; + } - $callback($node); - $neighbors = $this->getNeighbors($node); + $callback($node); + $neighbors = $this->getNeighbors($node); - foreach($neighbors as $neighbor) { - // todo: get neighbors needs to return in ordered way - $this->preOrder($neighbor, $callback); - } - } - - /** + foreach ($neighbors as $neighbor) { + // todo: get neighbors needs to return in ordered way + $this->preOrder($neighbor, $callback); + } + } + + /** * Perform action on tree in post-order. * * @param Node $node Tree node @@ -236,18 +236,18 @@ class Tree extends Graph * * @since 1.0.0 */ - public function postOrder(Node $node, \Closure $callback) { - if(count($this->nodes) === 0) { - return; - } - - $neighbors = $this->getNeighbors($node); + public function postOrder(Node $node, \Closure $callback) { + if (count($this->nodes) === 0) { + return; + } + + $neighbors = $this->getNeighbors($node); - foreach($neighbors as $neighbor) { - // todo: get neighbors needs to return in ordered way - $this->postOrder($neighbor, $callback); - } + foreach ($neighbors as $neighbor) { + // todo: get neighbors needs to return in ordered way + $this->postOrder($neighbor, $callback); + } - $callback($node); - } + $callback($node); + } } \ No newline at end of file diff --git a/Stdlib/Map/KeyType.php b/Stdlib/Map/KeyType.php index 13f304d68..bb4bef103 100644 --- a/Stdlib/Map/KeyType.php +++ b/Stdlib/Map/KeyType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Map; diff --git a/Stdlib/Map/MultiMap.php b/Stdlib/Map/MultiMap.php index 8874296f1..489864ad2 100644 --- a/Stdlib/Map/MultiMap.php +++ b/Stdlib/Map/MultiMap.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Map; @@ -92,7 +92,7 @@ class MultiMap implements \Countable $inserted = false; if ($this->keyType !== KeyType::SINGLE) { - $keys = [implode($keys, ':')]; + $keys = [implode(':', $keys)]; } foreach ($keys as $key) { @@ -186,14 +186,14 @@ class MultiMap implements \Countable $keys = Permutation::permut($key); foreach ($keys as $key => $value) { - $key = implode($value, ':'); + $key = implode(':', $value); if (isset($this->keys[$key])) { return $this->values[$this->keys[$key]]; } } } else { - $key = implode($key, ':'); + $key = implode(':', $key); } } @@ -235,12 +235,12 @@ class MultiMap implements \Countable $permutation = Permutation::permut($key); foreach ($permutation as $permut) { - if ($this->set(implode($permut, ':'), $value)) { + if ($this->set(implode(':', $permut), $value)) { return true; } } } else { - return $this->set(implode($key, ':'), $value); + return $this->set(implode(':', $key), $value); } return false; @@ -302,12 +302,12 @@ class MultiMap implements \Countable $removed = false; foreach ($keys as $key => $value) { - $removed |= $this->remove(implode($value, ':')); + $removed |= $this->remove(implode(':', $value)); } return $removed; } else { - return $this->remove(implode($key, ':')); + return $this->remove(implode(':', $key)); } } @@ -403,12 +403,12 @@ class MultiMap implements \Countable $removed = false; foreach ($keys as $key => $value) { - $removed |= $this->removeKey(implode($value, ':')); + $removed |= $this->removeKey(implode(':', $value)); } return $removed; } else { - return $this->removeKey(implode($key, ':')); + return $this->removeKey(implode(':', $key)); } } diff --git a/Stdlib/Map/OrderType.php b/Stdlib/Map/OrderType.php index 1dd55d46f..431257ef1 100644 --- a/Stdlib/Map/OrderType.php +++ b/Stdlib/Map/OrderType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Map; diff --git a/Stdlib/Queue/PriorityMode.php b/Stdlib/Queue/PriorityMode.php index 977190f08..a0dd0d31c 100644 --- a/Stdlib/Queue/PriorityMode.php +++ b/Stdlib/Queue/PriorityMode.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Queue; diff --git a/Stdlib/Queue/PriorityQueue.php b/Stdlib/Queue/PriorityQueue.php index c2e91e9f3..e4b8dfccb 100644 --- a/Stdlib/Queue/PriorityQueue.php +++ b/Stdlib/Queue/PriorityQueue.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Stdlib\Queue; diff --git a/System/File/ContainerInterface.php b/System/File/ContainerInterface.php index 403f4e1c0..1ff09559d 100644 --- a/System/File/ContainerInterface.php +++ b/System/File/ContainerInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File; @@ -315,11 +315,11 @@ interface ContainerInterface /** * Get the permissions id of the resource. * - * @return string Permissions (e.g. 0644); + * @return int Permissions (e.g. 0644); * * @since 1.0.0 */ - public function getPermission() : string; + public function getPermission() : int; /** * (Re-)Initialize resource diff --git a/System/File/ContentPutMode.php b/System/File/ContentPutMode.php index a7af7c67a..89f12ffbc 100644 --- a/System/File/ContentPutMode.php +++ b/System/File/ContentPutMode.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File; @@ -30,8 +30,8 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class ContentPutMode extends Enum { - /* public */ const APPEND = 1; - /* public */ const PREPEND = 2; - /* public */ const REPLACE = 4; - /* public */ const CREATE = 8; + /* public */ const APPEND = 1; + /* public */ const PREPEND = 2; + /* public */ const REPLACE = 4; + /* public */ const CREATE = 8; } \ No newline at end of file diff --git a/System/File/DirectoryInterface.php b/System/File/DirectoryInterface.php index bf6b52978..6d07252fa 100644 --- a/System/File/DirectoryInterface.php +++ b/System/File/DirectoryInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File; diff --git a/System/File/ExtensionType.php b/System/File/ExtensionType.php index 7d034ee66..1a39e8392 100644 --- a/System/File/ExtensionType.php +++ b/System/File/ExtensionType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File; diff --git a/System/File/FileInterface.php b/System/File/FileInterface.php index 3788fa189..6d15fd199 100644 --- a/System/File/FileInterface.php +++ b/System/File/FileInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File; @@ -29,7 +29,7 @@ namespace phpOMS\System\File; interface FileInterface extends ContainerInterface { - /** + /** * Save content to file. * * @param string $path File path to save the content to @@ -106,7 +106,7 @@ interface FileInterface extends ContainerInterface */ public static function extension(string $path) : string; - /** + /** * Save content to file. * * @param string $content Content to save in file diff --git a/System/File/FileUtils.php b/System/File/FileUtils.php index d1bd645b9..396c60f8c 100644 --- a/System/File/FileUtils.php +++ b/System/File/FileUtils.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File; @@ -60,23 +60,23 @@ class FileUtils { $extension = strtolower($extension); - if(in_array($extension, self::CODE_EXTENSION)) { + if (in_array($extension, self::CODE_EXTENSION)) { return ExtensionType::CODE; - } elseif(in_array($extension, self::TEXT_EXTENSION)) { + } elseif (in_array($extension, self::TEXT_EXTENSION)) { return ExtensionType::TEXT; - } elseif(in_array($extension, self::PRESENTATION_EXTENSION)) { + } elseif (in_array($extension, self::PRESENTATION_EXTENSION)) { return ExtensionType::PRESENTATION; - } elseif(in_array($extension, self::PDF_EXTENSION)) { + } elseif (in_array($extension, self::PDF_EXTENSION)) { return ExtensionType::PDF; - } elseif(in_array($extension, self::ARCHIVE_EXTENSION)) { + } elseif (in_array($extension, self::ARCHIVE_EXTENSION)) { return ExtensionType::ARCHIVE; - } elseif(in_array($extension, self::AUDIO_EXTENSION)) { + } elseif (in_array($extension, self::AUDIO_EXTENSION)) { return ExtensionType::AUDIO; - } elseif(in_array($extension, self::VIDEO_EXTENSION)) { + } elseif (in_array($extension, self::VIDEO_EXTENSION)) { return ExtensionType::VIDEO; - } elseif(in_array($extension, self::IMAGE_EXTENSION)) { + } elseif (in_array($extension, self::IMAGE_EXTENSION)) { return ExtensionType::IMAGE; - } elseif(in_array($extension, self::SPREADSHEET_EXTENSION)) { + } elseif (in_array($extension, self::SPREADSHEET_EXTENSION)) { return ExtensionType::SPREADSHEET; } @@ -94,13 +94,13 @@ class FileUtils */ public static function absolute(string $origPath) : string { - if(!file_exists($origPath)) { + if (!file_exists($origPath)) { $startsWithSlash = strpos($origPath, '/') === 0 ? '/' : ''; $path = []; $parts = explode('/', $origPath); - foreach($parts as $part) { + foreach ($parts as $part) { if (empty($part) || $part === '.') { continue; } diff --git a/System/File/Ftp/Directory.php b/System/File/Ftp/Directory.php index 1bb4e144b..8a92f60b8 100644 --- a/System/File/Ftp/Directory.php +++ b/System/File/Ftp/Directory.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File\Ftp; diff --git a/System/File/Ftp/File.php b/System/File/Ftp/File.php index 94378dbce..62ad4700f 100644 --- a/System/File/Ftp/File.php +++ b/System/File/Ftp/File.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File\Ftp; @@ -43,7 +43,7 @@ class File extends FileAbstract implements FileInterface { // todo: create all else cases, right now all getting handled the same way which is wrong $current = ftp_pwd($con); - if(!ftp_chdir($con, File::dirpath($path))) { + if (!ftp_chdir($con, File::dirpath($path))) { return false; } @@ -80,7 +80,7 @@ class File extends FileAbstract implements FileInterface $temp = fopen('php://temp', 'r+'); $current = ftp_pwd($con); - if(ftp_chdir($con, File::dirpath($path)) && ftp_fget($con, $temp, $path, FTP_BINARY, 0)) { + if (ftp_chdir($con, File::dirpath($path)) && ftp_fget($con, $temp, $path, FTP_BINARY, 0)) { rewind($temp); $content = stream_get_contents($temp); } @@ -121,8 +121,8 @@ class File extends FileAbstract implements FileInterface public static function exists(string $path) : bool { - if(($current = ftp_pwd($con)) !== LocalFile::dirpath($path)) { - if(!ftp_chdir($con, $path)) { + if (($current = ftp_pwd($con)) !== LocalFile::dirpath($path)) { + if (!ftp_chdir($con, $path)) { return false; } } @@ -203,7 +203,7 @@ class File extends FileAbstract implements FileInterface if (is_array($files = ftp_rawlist($con, self::dirpath($path)))) { foreach ($files as $fileData) { - if(strpos($fileData, self::name($path)) !== false) { + if (strpos($fileData, self::name($path)) !== false) { $chunks = preg_split("/\s+/", $fileData); $items['permission'] = $chungs[0]; @@ -253,7 +253,7 @@ class File extends FileAbstract implements FileInterface */ public static function copy(string $from, string $to, bool $overwrite = false) : bool { - if(($src = self::get($from)) === false) { + if (($src = self::get($from)) === false) { return false; } diff --git a/System/File/Ftp/FtpStorage.php b/System/File/Ftp/FtpStorage.php index 7aad853e1..f49daf22d 100644 --- a/System/File/Ftp/FtpStorage.php +++ b/System/File/Ftp/FtpStorage.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File\Ftp; use phpOMS\System\File\ContainerInterface; @@ -40,7 +40,7 @@ class FtpStorage extends StorageAbstract public static function getInstance() : StorageAbstract { - if(!isset(self::$instance)) { + if (!isset(self::$instance)) { self::$instance = new self(); } @@ -49,7 +49,7 @@ class FtpStorage extends StorageAbstract public function connect(string $uri, int $port = 21, bool $mode = true, string $login = null, string $pass = null, bool $ssl = false) : bool { - if($ssl) { + if ($ssl) { $this->con = ftp_connect($uri, $port); } else { $this->con = ftp_ssl_connect($uri, $port); @@ -57,14 +57,14 @@ class FtpStorage extends StorageAbstract ftp_pasv($this->con, $mode); - if(isset($login, $pass)) { + if (isset($login, $pass)) { ftp_login($this->con, $login, $pass); } } public function __destruct() { - if(isset($this->con)) { + if (isset($this->con)) { ftp_close($this->con); $this->con = null; } diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index 25f1c2aea..b7f2e7d28 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File\Local; @@ -115,7 +115,7 @@ class Directory extends FileAbstract implements DirectoryInterface new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item ) { - if($item->getExtension() === $extension) { + if ($item->getExtension() === $extension) { $list[] = str_replace('\\', '/', $iterator->getSubPathName()); } } @@ -156,27 +156,23 @@ class Directory extends FileAbstract implements DirectoryInterface */ public static function size(string $dir, bool $recursive = true) : int { - if (!file_exists($dir)) { + if (!file_exists($dir) || !is_readable($dir)) { throw new PathException($dir); } $countSize = 0; - $count = 0; + $dir_array = scandir($dir); - if (is_readable($dir)) { - $dir_array = scandir($dir); + foreach ($dir_array as $key => $filename) { + if ($filename === ".." || $filename === ".") { + continue; + } - foreach ($dir_array as $key => $filename) { - if ($filename != ".." && $filename != ".") { - if (is_dir($dir . "/" . $filename) && $recursive) { - $countSize += self::size($dir . "/" . $filename, $recursive); - } else { - if (is_file($dir . "/" . $filename)) { - $countSize += filesize($dir . "/" . $filename); - $count++; - } - } - } + $path = $dir . "/" . $filename; + if (is_dir($path) && $recursive) { + $countSize += self::size($path, $recursive); + } elseif (is_file($path)) { + $countSize += filesize($path); } } @@ -254,7 +250,7 @@ class Directory extends FileAbstract implements DirectoryInterface */ public static function created(string $path) : \DateTime { - if(!file_exists($path)) { + if (!file_exists($path)) { throw new PathException($path); } @@ -312,14 +308,12 @@ class Directory extends FileAbstract implements DirectoryInterface throw new PathException($from); } - if(!$overwrite && file_exists($to)) { - return false; - } - if (!file_exists($to)) { self::create($to, 0644, true); - } elseif($overwrite && file_exists($to)) { + } elseif ($overwrite && file_exists($to)) { self::delete($to); + } else { + return false; } foreach ($iterator = new \RecursiveIteratorIterator( @@ -347,7 +341,7 @@ class Directory extends FileAbstract implements DirectoryInterface if (!$overwrite && file_exists($to)) { return false; - } elseif($overwrite && file_exists($to)) { + } elseif ($overwrite && file_exists($to)) { self::delete($to); } @@ -400,7 +394,7 @@ class Directory extends FileAbstract implements DirectoryInterface public static function create(string $path, int $permission = 0644, bool $recursive = false) : bool { if (!file_exists($path)) { - if(!$recursive && !file_exists(self::parent($path))) { + if (!$recursive && !file_exists(self::parent($path))) { return false; } diff --git a/System/File/Local/File.php b/System/File/Local/File.php index 6cd2954fe..083bbf317 100644 --- a/System/File/Local/File.php +++ b/System/File/Local/File.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File\Local; @@ -74,9 +74,9 @@ class File extends FileAbstract implements FileInterface || (($mode & ContentPutMode::REPLACE) === ContentPutMode::REPLACE && $exists) || (!$exists && ($mode & ContentPutMode::CREATE) === ContentPutMode::CREATE) ) { - if(($mode & ContentPutMode::APPEND) === ContentPutMode::APPEND && $exists) { + if (($mode & ContentPutMode::APPEND) === ContentPutMode::APPEND && $exists) { file_put_contents($path, file_get_contents($path) . $content); - } elseif(($mode & ContentPutMode::PREPEND) === ContentPutMode::PREPEND && $exists) { + } elseif (($mode & ContentPutMode::PREPEND) === ContentPutMode::PREPEND && $exists) { file_put_contents($path, $content . file_get_contents($path)); } else { if (!Directory::exists(dirname($path))) { @@ -268,7 +268,7 @@ class File extends FileAbstract implements FileInterface Directory::create(dirname($to), 0644, true); } - if($overwrite && file_exists($to)) { + if ($overwrite && file_exists($to)) { unlink($to); } @@ -294,7 +294,7 @@ class File extends FileAbstract implements FileInterface Directory::create(dirname($to), 0644, true); } - if($overwrite && file_exists($to)) { + if ($overwrite && file_exists($to)) { unlink($to); } @@ -362,7 +362,7 @@ class File extends FileAbstract implements FileInterface Directory::create(dirname($path), 0644, true); } - if(!is_writable(dirname($path))) { + if (!is_writable(dirname($path))) { return false; } diff --git a/System/File/Local/FileAbstract.php b/System/File/Local/FileAbstract.php index 46a81b8ab..e428238bd 100644 --- a/System/File/Local/FileAbstract.php +++ b/System/File/Local/FileAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File\Local; use phpOMS\System\File\ContainerInterface; @@ -88,7 +88,7 @@ abstract class FileAbstract implements ContainerInterface /** * Permission. * - * @var string + * @var int * @since 1.0.0 */ protected $permission = 0644; @@ -176,7 +176,7 @@ abstract class FileAbstract implements ContainerInterface /** * {@inheritdoc} */ - public function getPermission() : string + public function getPermission() : int { return $this->permission; } diff --git a/System/File/Local/LocalStorage.php b/System/File/Local/LocalStorage.php index ea248c7f5..073893799 100644 --- a/System/File/Local/LocalStorage.php +++ b/System/File/Local/LocalStorage.php @@ -11,10 +11,9 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File\Local; -use phpOMS\System\File\ContainerInterface; use phpOMS\System\File\StorageAbstract; use phpOMS\System\File\PathException; @@ -39,7 +38,7 @@ class LocalStorage extends StorageAbstract public static function getInstance() : StorageAbstract { - if(!isset(self::$instance)) { + if (!isset(self::$instance)) { self::$instance = new self(); } @@ -184,7 +183,7 @@ class LocalStorage extends StorageAbstract */ public static function put(string $path, string $content, int $mode = 0) : bool { - if(is_dir($path)) { + if (is_dir($path)) { throw new PathException($path); } @@ -196,7 +195,7 @@ class LocalStorage extends StorageAbstract */ public static function get(string $path) : string { - if(is_dir($path)) { + if (is_dir($path)) { throw new PathException($path); } @@ -208,7 +207,7 @@ class LocalStorage extends StorageAbstract */ public static function list(string $path, string $filter = '*') : array { - if(is_file($path)) { + if (is_file($path)) { throw new PathException($path); } @@ -228,7 +227,7 @@ class LocalStorage extends StorageAbstract */ public static function set(string $path, string $content) : bool { - if(is_dir($path)) { + if (is_dir($path)) { throw new PathException($path); } @@ -240,7 +239,7 @@ class LocalStorage extends StorageAbstract */ public static function append(string $path, string $content) : bool { - if(is_dir($path)) { + if (is_dir($path)) { throw new PathException($path); } @@ -252,7 +251,7 @@ class LocalStorage extends StorageAbstract */ public static function prepend(string $path, string $content) : bool { - if(is_dir($path)) { + if (is_dir($path)) { throw new PathException($path); } @@ -264,7 +263,7 @@ class LocalStorage extends StorageAbstract */ public static function extension(string $path) : string { - if(is_dir($path)) { + if (is_dir($path)) { throw new PathException($path); } diff --git a/System/File/PathException.php b/System/File/PathException.php index 5962a5a60..d99b422f0 100644 --- a/System/File/PathException.php +++ b/System/File/PathException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File; @@ -31,7 +31,7 @@ class PathException extends \UnexpectedValueException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/System/File/PermissionException.php b/System/File/PermissionException.php index b42c4f98e..b59dbf67e 100644 --- a/System/File/PermissionException.php +++ b/System/File/PermissionException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File; @@ -31,7 +31,7 @@ class PermissionException extends \RuntimeException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/System/File/Storage.php b/System/File/Storage.php index f9e3ab017..d7d464215 100644 --- a/System/File/Storage.php +++ b/System/File/Storage.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File; @@ -61,9 +61,9 @@ final class Storage public static function env(string $env = 'local') : StorageAbstract { if (isset(self::$registered[$env])) { - if(is_string(self::$registered[$env])) { + if (is_string(self::$registered[$env])) { $env = self::$registered[$env]::getInstance(); - } elseif(self::$registered[$env] instanceof StorageAbstract || self::$registered[$env] instanceof ContainerInterface) { + } elseif (self::$registered[$env] instanceof StorageAbstract || self::$registered[$env] instanceof ContainerInterface) { $env = self::$registered[$env]; } else { throw new \Exception('Invalid type'); @@ -78,7 +78,7 @@ final class Storage $env = $env::getInstance(); self::$registered[$stg] = $env; - } catch(\Throwable $e) { + } catch (\Throwable $e) { throw new \Exception(); } } diff --git a/System/File/StorageAbstract.php b/System/File/StorageAbstract.php index 215930f6c..0fffb96ac 100644 --- a/System/File/StorageAbstract.php +++ b/System/File/StorageAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System\File; @@ -72,120 +72,120 @@ abstract class StorageAbstract /** * {@inheritdoc} */ - public abstract static function created(string $path) : \DateTime; + abstract public static function created(string $path) : \DateTime; /** * {@inheritdoc} */ - public abstract static function changed(string $path) : \DateTime; + abstract public static function changed(string $path) : \DateTime; /** * {@inheritdoc} */ - public abstract static function owner(string $path) : int; + abstract public static function owner(string $path) : int; /** * {@inheritdoc} */ - public abstract static function permission(string $path) : int; + abstract public static function permission(string $path) : int; /** * {@inheritdoc} */ - public abstract static function parent(string $path) : string; + abstract public static function parent(string $path) : string; /** * {@inheritdoc} */ - public abstract static function create(string $path) : bool; + abstract public static function create(string $path) : bool; /** * {@inheritdoc} */ - public abstract static function delete(string $path) : bool; + abstract public static function delete(string $path) : bool; /** * {@inheritdoc} */ - public abstract static function copy(string $from, string $to, bool $overwrite = false) : bool; + abstract public static function copy(string $from, string $to, bool $overwrite = false) : bool; /** * {@inheritdoc} */ - public abstract static function move(string $from, string $to, bool $overwrite = false) : bool; + abstract public static function move(string $from, string $to, bool $overwrite = false) : bool; /** * {@inheritdoc} */ - public abstract static function size(string $path, bool $recursive = true) : int; + abstract public static function size(string $path, bool $recursive = true) : int; /** * {@inheritdoc} */ - public abstract static function exists(string $path) : bool; + abstract public static function exists(string $path) : bool; /** * {@inheritdoc} */ - public abstract static function name(string $path) : string; + abstract public static function name(string $path) : string; /** * {@inheritdoc} */ - public abstract static function basename(string $path) : string; + abstract public static function basename(string $path) : string; /** * {@inheritdoc} */ - public abstract static function dirname(string $path) : string; + abstract public static function dirname(string $path) : string; /** * {@inheritdoc} */ - public abstract static function dirpath(string $path) : string; + abstract public static function dirpath(string $path) : string; /** * {@inheritdoc} */ - public abstract static function list(string $path, string $filter = '*') : array; + abstract public static function list(string $path, string $filter = '*') : array; /** * {@inheritdoc} */ - public abstract static function count(string $path, bool $recursive = true, array $ignore = []) : int; + abstract public static function count(string $path, bool $recursive = true, array $ignore = []) : int; /** * {@inheritdoc} */ - public abstract static function put(string $path, string $content, int $mode = 0) : bool; + abstract public static function put(string $path, string $content, int $mode = 0) : bool; /** * {@inheritdoc} */ - public abstract static function get(string $path) : string; + abstract public static function get(string $path) : string; /** * {@inheritdoc} */ - public abstract static function sanitize(string $path, string $replace = '') : string; + abstract public static function sanitize(string $path, string $replace = '') : string; /** * {@inheritdoc} */ - public abstract static function set(string $path, string $content) : bool; + abstract public static function set(string $path, string $content) : bool; /** * {@inheritdoc} */ - public abstract static function append(string $path, string $content) : bool; + abstract public static function append(string $path, string $content) : bool; /** * {@inheritdoc} */ - public abstract static function prepend(string $path, string $content) : bool; + abstract public static function prepend(string $path, string $content) : bool; /** * {@inheritdoc} */ - public abstract static function extension(string $path) : string; + abstract public static function extension(string $path) : string; } diff --git a/System/MimeType.php b/System/MimeType.php index 1d52aad06..6c935391b 100644 --- a/System/MimeType.php +++ b/System/MimeType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System; diff --git a/System/OperatingSystem.php b/System/OperatingSystem.php index 97ee9766b..d7ac33dae 100644 --- a/System/OperatingSystem.php +++ b/System/OperatingSystem.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System; @@ -35,11 +35,11 @@ final class OperatingSystem */ public static function getSystem() : int { - if(stristr(PHP_OS, 'DAR') !== false) { + if (stristr(PHP_OS, 'DAR') !== false) { return SystemType::OSX; - } elseif(stristr(PHP_OS, 'WIN') !== false) { + } elseif (stristr(PHP_OS, 'WIN') !== false) { return SystemType::WIN; - } elseif(stristr(PHP_OS, 'LINUX') !== false) { + } elseif (stristr(PHP_OS, 'LINUX') !== false) { return SystemType::LINUX; } diff --git a/System/SystemType.php b/System/SystemType.php index 5c630fe64..52e870d21 100644 --- a/System/SystemType.php +++ b/System/SystemType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System; @@ -30,8 +30,8 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class SystemType extends Enum { - /* public */ const UNKNOWN = 1; - /* public */ const WIN = 2; - /* public */ const LINUX = 3; - /* public */ const OSX = 4; + /* public */ const UNKNOWN = 1; + /* public */ const WIN = 2; + /* public */ const LINUX = 3; + /* public */ const OSX = 4; } \ No newline at end of file diff --git a/System/SystemUtils.php b/System/SystemUtils.php index e7e80cc49..0ebfed499 100644 --- a/System/SystemUtils.php +++ b/System/SystemUtils.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\System; @@ -46,10 +46,12 @@ class SystemUtils */ public static function getRAM() : int { - $mem = null; + $mem = 0; if (stristr(PHP_OS, 'WIN')) { exec('wmic memorychip get capacity', $mem); + + /** @var array $mem */ $mem = array_sum($mem) / 1024; } elseif (stristr(PHP_OS, 'LINUX')) { $fh = fopen('/proc/meminfo', 'r'); @@ -62,6 +64,7 @@ class SystemUtils break; } } + fclose($fh); } @@ -79,9 +82,7 @@ class SystemUtils { $memusage = 0; - if (stristr(PHP_OS, 'WIN')) { - - } elseif (stristr(PHP_OS, 'LINUX')) { + if (stristr(PHP_OS, 'LINUX')) { $free = shell_exec('free'); $free = (string) trim($free); $free_arr = explode("\n", $free); diff --git a/UnhandledHandler.php b/UnhandledHandler.php index c7595be84..7a6f9cae8 100644 --- a/UnhandledHandler.php +++ b/UnhandledHandler.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS; diff --git a/Uri/Http.php b/Uri/Http.php index c410ecbe4..d9480eb82 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Uri; @@ -281,9 +281,9 @@ class Http implements UriInterface /** * {@inheritdoc} */ - public function getQuery(string $key = null) /* : ?string */ + public function getQuery(string $key = null) : string { - if(isset($key)) { + if (isset($key)) { $key = strtolower($key); return $this->query[$key] ?? ''; diff --git a/Uri/InvalidUriException.php b/Uri/InvalidUriException.php index 9da6c3316..43ba42ca5 100644 --- a/Uri/InvalidUriException.php +++ b/Uri/InvalidUriException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Uri; @@ -31,7 +31,7 @@ class InvalidUriException extends \UnexpectedValueException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 1e08c1d75..c00ba0663 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Uri; @@ -120,7 +120,7 @@ class UriFactory self::setQuery(':pass', $uri->getPass()); $data = $uri->getQueryArray(); - foreach($data as $key => $value) { + foreach ($data as $key => $value) { self::setQuery('?' . $key, $value); } } @@ -136,7 +136,7 @@ class UriFactory */ public static function clear(string $key) : bool { - if(isset(self::$uri[$key])) { + if (isset(self::$uri[$key])) { unset(self::$uri[$key]); return true; @@ -158,8 +158,8 @@ class UriFactory { $success = false; - foreach(self::$uri as $key => $value) { - if(((bool) preg_match('~^' . $pattern . '$~', $key))) { + foreach (self::$uri as $key => $value) { + if (((bool) preg_match('~^' . $pattern . '$~', $key))) { unset(self::$uri[$key]); $success = true; } @@ -187,7 +187,6 @@ class UriFactory $full = $parts[1]; $pars = explode('&', $full); $comps = []; - $spl = null; $length = count($pars); for ($i = 0; $i < $length; $i++) { diff --git a/Uri/UriInterface.php b/Uri/UriInterface.php index 50617e95c..0b311993b 100644 --- a/Uri/UriInterface.php +++ b/Uri/UriInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Uri; @@ -117,11 +117,11 @@ interface UriInterface * * @param string $key Query key * - * @return string|array + * @return string * * @since 1.0.0 */ - public function getQuery(string $key = null); + public function getQuery(string $key = null) : string; /** * Get fragment. diff --git a/Uri/UriScheme.php b/Uri/UriScheme.php index 1f8f6df2d..5c854437d 100644 --- a/Uri/UriScheme.php +++ b/Uri/UriScheme.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Uri; diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index 0f66a1faf..7995b7a29 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils; @@ -74,7 +74,7 @@ class ArrayUtils } /** - * Check if needle exists in multidimensional array. + * Set element in array by path * * @param string $path Path to element * @param array $data Array @@ -97,21 +97,42 @@ class ArrayUtils if ($overwrite) { $current = $value; + } elseif (is_array($current) && !is_array($value)) { + $current[] = $value; + } elseif (is_array($current) && is_array($value)) { + $current += $value; + } elseif (is_scalar($current) && $current !== null) { + $current = [$current, $value]; } else { - if (is_array($current) && !is_array($value)) { - $current[] = $value; - } elseif (is_array($current) && is_array($value)) { - $current += $value; - } elseif (is_scalar($current) && $current !== null) { - $current = [$current, $value]; - } else { - $current = $value; - } + $current = $value; } return $data; } + /** + * Get element of array by path + * + * @param string $path Path to element + * @param array $data Array + * @param string $delim Delimiter for path + * + * @return mixed + * + * @since 1.0.0 + */ + public static function getArray(string $path, array $data, string $delim = '/') + { + $pathParts = explode($delim, trim($path, $delim)); + $current = $data; + + foreach ($pathParts as $key) { + $current = $current[$key]; + } + + return $current; + } + /** * Check if needle exists in multidimensional array. * @@ -133,7 +154,7 @@ class ArrayUtils $found = self::inArrayRecursive($needle, $item); if ($found) { - break; + return true; } } } @@ -153,8 +174,8 @@ class ArrayUtils */ public static function anyInArray(array $needles, array $haystack) : bool { - foreach($needles as $needle) { - if(in_array($needle, $haystack)) { + foreach ($needles as $needle) { + if (in_array($needle, $haystack)) { return true; } } @@ -174,8 +195,8 @@ class ArrayUtils */ public static function allInArray(array $needles, array $haystack) : bool { - foreach($needles as $needle) { - if(!in_array($needle, $haystack)) { + foreach ($needles as $needle) { + if (!in_array($needle, $haystack)) { return false; } } diff --git a/Utils/Barcode/Aztec.php b/Utils/Barcode/Aztec.php index c54bbc73b..548f2ab19 100644 --- a/Utils/Barcode/Aztec.php +++ b/Utils/Barcode/Aztec.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/Barcode/C128Abstract.php b/Utils/Barcode/C128Abstract.php index 135f055f1..f0a84592b 100644 --- a/Utils/Barcode/C128Abstract.php +++ b/Utils/Barcode/C128Abstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/Barcode/C128a.php b/Utils/Barcode/C128a.php index b3d953750..591777085 100644 --- a/Utils/Barcode/C128a.php +++ b/Utils/Barcode/C128a.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/Barcode/C128b.php b/Utils/Barcode/C128b.php index 7b2464130..8023cdbc3 100644 --- a/Utils/Barcode/C128b.php +++ b/Utils/Barcode/C128b.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/Barcode/C128c.php b/Utils/Barcode/C128c.php index 243b734b6..9f41b5c20 100644 --- a/Utils/Barcode/C128c.php +++ b/Utils/Barcode/C128c.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/Barcode/C25.php b/Utils/Barcode/C25.php index 642e70253..3b9b7d860 100644 --- a/Utils/Barcode/C25.php +++ b/Utils/Barcode/C25.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/Barcode/C39.php b/Utils/Barcode/C39.php index c09e3c7ba..84a8d53c9 100644 --- a/Utils/Barcode/C39.php +++ b/Utils/Barcode/C39.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/Barcode/Codebar.php b/Utils/Barcode/Codebar.php index 841d0f264..dd34d1dec 100644 --- a/Utils/Barcode/Codebar.php +++ b/Utils/Barcode/Codebar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/Barcode/Datamatrix.php b/Utils/Barcode/Datamatrix.php index 0cd822e88..0dbbd785d 100644 --- a/Utils/Barcode/Datamatrix.php +++ b/Utils/Barcode/Datamatrix.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/Barcode/HIBCC.php b/Utils/Barcode/HIBCC.php index 3c20394e3..4aa09952b 100644 --- a/Utils/Barcode/HIBCC.php +++ b/Utils/Barcode/HIBCC.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/Barcode/OrientationType.php b/Utils/Barcode/OrientationType.php index 38bc5ebb1..144d7e12c 100644 --- a/Utils/Barcode/OrientationType.php +++ b/Utils/Barcode/OrientationType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/Barcode/QR.php b/Utils/Barcode/QR.php index d93397a09..8d6ff8dce 100644 --- a/Utils/Barcode/QR.php +++ b/Utils/Barcode/QR.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Barcode; diff --git a/Utils/ColorUtils.php b/Utils/ColorUtils.php index 51f9a797c..44a36098f 100644 --- a/Utils/ColorUtils.php +++ b/Utils/ColorUtils.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils; diff --git a/Utils/Compression/CompressionInterface.php b/Utils/Compression/CompressionInterface.php index 9368cd280..6e52a591a 100644 --- a/Utils/Compression/CompressionInterface.php +++ b/Utils/Compression/CompressionInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Compression; diff --git a/Utils/Compression/LZW.php b/Utils/Compression/LZW.php index d50504208..7bd041a4b 100644 --- a/Utils/Compression/LZW.php +++ b/Utils/Compression/LZW.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Compression; diff --git a/Utils/Converter/AngleType.php b/Utils/Converter/AngleType.php index 21137e848..36eedd12f 100644 --- a/Utils/Converter/AngleType.php +++ b/Utils/Converter/AngleType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/AreaType.php b/Utils/Converter/AreaType.php index d499dbb92..5f992a625 100644 --- a/Utils/Converter/AreaType.php +++ b/Utils/Converter/AreaType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/Currency.php b/Utils/Converter/Currency.php index 06be05c61..4ff799f05 100644 --- a/Utils/Converter/Currency.php +++ b/Utils/Converter/Currency.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; @@ -99,7 +99,7 @@ class Currency { if (!isset(self::$ecbCurrencies)) { $request = new Request(new Http('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml')); - $request->setMethod(RequestMethod::GET); + $request->setMethod(RequestMethod::GET); $xml = new \SimpleXMLElement(Rest::request($request)); diff --git a/Utils/Converter/EnergyPowerType.php b/Utils/Converter/EnergyPowerType.php index caaa22def..bfd4353a9 100644 --- a/Utils/Converter/EnergyPowerType.php +++ b/Utils/Converter/EnergyPowerType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/File.php b/Utils/Converter/File.php index 14430409c..74aae80d8 100644 --- a/Utils/Converter/File.php +++ b/Utils/Converter/File.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/FileSizeType.php b/Utils/Converter/FileSizeType.php index 36c68c59e..e8bb0cdde 100644 --- a/Utils/Converter/FileSizeType.php +++ b/Utils/Converter/FileSizeType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/Ip.php b/Utils/Converter/Ip.php index 87fa6c88e..6966a0d75 100644 --- a/Utils/Converter/Ip.php +++ b/Utils/Converter/Ip.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/LengthType.php b/Utils/Converter/LengthType.php index bfda7cd3c..1eacb6784 100644 --- a/Utils/Converter/LengthType.php +++ b/Utils/Converter/LengthType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/Measurement.php b/Utils/Converter/Measurement.php index 8975cf0b2..e765f4d29 100644 --- a/Utils/Converter/Measurement.php +++ b/Utils/Converter/Measurement.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/Numeric.php b/Utils/Converter/Numeric.php index c77e628b0..a833dde3d 100644 --- a/Utils/Converter/Numeric.php +++ b/Utils/Converter/Numeric.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/PressureType.php b/Utils/Converter/PressureType.php index 554b10c22..68164c671 100644 --- a/Utils/Converter/PressureType.php +++ b/Utils/Converter/PressureType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/SpeedType.php b/Utils/Converter/SpeedType.php index 4f7affa01..5dadade96 100644 --- a/Utils/Converter/SpeedType.php +++ b/Utils/Converter/SpeedType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/TemperatureType.php b/Utils/Converter/TemperatureType.php index a79f8d6e7..51af6d8d4 100644 --- a/Utils/Converter/TemperatureType.php +++ b/Utils/Converter/TemperatureType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/TimeType.php b/Utils/Converter/TimeType.php index 5dc8080a6..5be37ae52 100644 --- a/Utils/Converter/TimeType.php +++ b/Utils/Converter/TimeType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/VolumeType.php b/Utils/Converter/VolumeType.php index 738e7346d..0b9903394 100644 --- a/Utils/Converter/VolumeType.php +++ b/Utils/Converter/VolumeType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/Converter/WeightType.php b/Utils/Converter/WeightType.php index b0c3ad8f2..bce405600 100644 --- a/Utils/Converter/WeightType.php +++ b/Utils/Converter/WeightType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Converter; diff --git a/Utils/EDI/AnsiX12/Component/BEG.php b/Utils/EDI/AnsiX12/Component/BEG.php index efbdc0101..0b49fa02a 100644 --- a/Utils/EDI/AnsiX12/Component/BEG.php +++ b/Utils/EDI/AnsiX12/Component/BEG.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12\Components; diff --git a/Utils/EDI/AnsiX12/Component/BIG.php b/Utils/EDI/AnsiX12/Component/BIG.php index 9709c1b00..e8f90f9f6 100644 --- a/Utils/EDI/AnsiX12/Component/BIG.php +++ b/Utils/EDI/AnsiX12/Component/BIG.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12\Components; @@ -45,7 +45,7 @@ class BIG public function setInvoiceNumber(string $invoice) /* : void */ { - if(strlen($invoice) < 1 || strlen($invoice) > 22) { + if (strlen($invoice) < 1 || strlen($invoice) > 22) { throw new \Exception(); } @@ -69,7 +69,7 @@ class BIG public function setPurchaseNumber(string $purchase) /* : void */ { - if(strlen($purchase) < 1 || strlen($purchase) > 22) { + if (strlen($purchase) < 1 || strlen($purchase) > 22) { throw new \Exception(); } @@ -83,7 +83,7 @@ class BIG public function setTransactionTypeCode(int $code) /* : void */ { - if($code < 10 || $code > 99) { + if ($code < 10 || $code > 99) { throw new \Exception(); } diff --git a/Utils/EDI/AnsiX12/Component/GS.php b/Utils/EDI/AnsiX12/Component/GS.php index 82b0ab789..bfdad1997 100644 --- a/Utils/EDI/AnsiX12/Component/GS.php +++ b/Utils/EDI/AnsiX12/Component/GS.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12\Components; @@ -59,7 +59,7 @@ class GS public function setFunctionalIdentifierCode(string $code) /* : void */ { - if(!FunctionalIdentifierCode::isValidValue($code)) { + if (!FunctionalIdentifierCode::isValidValue($code)) { throw \Exception(); } @@ -73,7 +73,7 @@ class GS public function setApplicationSenderCode(string $code) /* : void */ { - if(strlen($code) < 2 || strlen($code) > 15) { + if (strlen($code) < 2 || strlen($code) > 15) { throw new \Exception(); } @@ -87,7 +87,7 @@ class GS public function setApplicationReceiverCode(string $code) /* : void */ { - if(strlen($code) < 2 || strlen($code) > 15) { + if (strlen($code) < 2 || strlen($code) > 15) { throw new \Exception(); } @@ -116,7 +116,7 @@ class GS public function setGroupControlNumber(int $number) /* : void */ { - if($number < 0) { + if ($number < 0) { throw new \Exception(); } @@ -130,7 +130,7 @@ class GS public function setResponsibleAgencyCode(int $code) /* : void */ { - if($code < 0 || $code > 99) { + if ($code < 0 || $code > 99) { throw new \Exception(); } diff --git a/Utils/EDI/AnsiX12/Component/ISA.php b/Utils/EDI/AnsiX12/Component/ISA.php index 0c537d6b4..2d1056d11 100644 --- a/Utils/EDI/AnsiX12/Component/ISA.php +++ b/Utils/EDI/AnsiX12/Component/ISA.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12\Components; @@ -207,7 +207,7 @@ class ISA public function setAuthorizationInformationQualifier(int $qualifer) /* : void */ { - if($qualifer > 99) { + if ($qualifer > 99) { throw new \Exception(); } @@ -221,7 +221,7 @@ class ISA public function setAuthorizationInformation(string $information) /* : void */ { - if(strlen($information) > 10) { + if (strlen($information) > 10) { throw new \Exception(); } @@ -235,7 +235,7 @@ class ISA public function setSecurityInformationQualifer(int $qualifer) /* : void */ { - if($qualifer > 99) { + if ($qualifer > 99) { throw new \Exception(); } @@ -249,7 +249,7 @@ class ISA public function setSecurityInformation(string $information) /* : void */ { - if(strlen($information) > 10) { + if (strlen($information) > 10) { throw new \Exception(); } @@ -263,7 +263,7 @@ class ISA public function setInterchangeIdQualifier(int $qualifer) /* : void */ { - if($qualifer > 99) { + if ($qualifer > 99) { throw new \Exception(); } @@ -278,7 +278,7 @@ class ISA public function setInterchangeSender(string $information) /* : void */ { - if(strlen($information) > 15) { + if (strlen($information) > 15) { throw new \Exception(); } @@ -292,7 +292,7 @@ class ISA public function setInterchangeReceiver(string $information) /* : void */ { - if(strlen($information) > 15) { + if (strlen($information) > 15) { throw new \Exception(); } @@ -321,7 +321,7 @@ class ISA public function setInterchangeControlStandardId(string $id) /* : void */ { - if(strlen($id) !== 1) { + if (strlen($id) !== 1) { throw new \Exception(); } @@ -335,7 +335,7 @@ class ISA public function setInterchangeControlVersionNumber(int $version) /* : void */ { - if($version > 99999) { + if ($version > 99999) { throw new \Exception(); } @@ -349,7 +349,7 @@ class ISA public function setInterchangeControlNumber(int $number) /* : void */ { - if($number > 999999999) { + if ($number > 999999999) { throw new \Exception(); } @@ -373,7 +373,7 @@ class ISA public function setUsageUndicator(string $id) /* : void */ { - if(strlen($id) !== 1) { + if (strlen($id) !== 1) { throw new \Exception(); } diff --git a/Utils/EDI/AnsiX12/Component/ST.php b/Utils/EDI/AnsiX12/Component/ST.php index a82ee7897..27ec6ce65 100644 --- a/Utils/EDI/AnsiX12/Component/ST.php +++ b/Utils/EDI/AnsiX12/Component/ST.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12\Components; @@ -39,7 +39,7 @@ class ST public function setTransactionSetIdentifierCode(int $idCode) { - if($idCode < 100 || $idCode > 999) { + if ($idCode < 100 || $idCode > 999) { throw new \Exception(); } @@ -53,7 +53,7 @@ class ST public function setTransactionSetControlNumber(string $controlNumber) { - if(strlen($controlNumber) < 4 || strlen($controlNumber) > 9) { + if (strlen($controlNumber) < 4 || strlen($controlNumber) > 9) { throw new \Exception(); } diff --git a/Utils/EDI/AnsiX12/EDIAbstract.php b/Utils/EDI/AnsiX12/EDIAbstract.php index df3f8576c..87ead16d1 100644 --- a/Utils/EDI/AnsiX12/EDIAbstract.php +++ b/Utils/EDI/AnsiX12/EDIAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12; diff --git a/Utils/EDI/AnsiX12/FunctionalGroupHeader.php b/Utils/EDI/AnsiX12/FunctionalGroupHeader.php index d5a2b585a..1c820b29b 100644 --- a/Utils/EDI/AnsiX12/FunctionalGroupHeader.php +++ b/Utils/EDI/AnsiX12/FunctionalGroupHeader.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12; @@ -59,7 +59,7 @@ class FunctionalGroupHedaer public function setFunctionalIdentifierCode(string $code) /* : void */ { - if(!FunctionalIdentifierCode::isValidValue($code)) { + if (!FunctionalIdentifierCode::isValidValue($code)) { throw \Exception(); } @@ -73,7 +73,7 @@ class FunctionalGroupHedaer public function setApplicationSenderCode(string $code) /* : void */ { - if(strlen($code) < 2 || strlen($code) > 15) { + if (strlen($code) < 2 || strlen($code) > 15) { throw new \Exception(); } @@ -87,7 +87,7 @@ class FunctionalGroupHedaer public function setApplicationReceiverCode(string $code) /* : void */ { - if(strlen($code) < 2 || strlen($code) > 15) { + if (strlen($code) < 2 || strlen($code) > 15) { throw new \Exception(); } @@ -116,7 +116,7 @@ class FunctionalGroupHedaer public function setGroupControlNumber(int $number) /* : void */ { - if($number < 0) { + if ($number < 0) { throw new \Exception(); } @@ -130,7 +130,7 @@ class FunctionalGroupHedaer public function setResponsibleAgencyCode(int $code) /* : void */ { - if($code < 0 || $code > 99) { + if ($code < 0 || $code > 99) { throw new \Exception(); } diff --git a/Utils/EDI/AnsiX12/Header.php b/Utils/EDI/AnsiX12/Header.php index 5bb602420..7811ccc47 100644 --- a/Utils/EDI/AnsiX12/Header.php +++ b/Utils/EDI/AnsiX12/Header.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12; diff --git a/Utils/EDI/AnsiX12/InterchangeControlHeader.php b/Utils/EDI/AnsiX12/InterchangeControlHeader.php index fcfd74f95..83759ab45 100644 --- a/Utils/EDI/AnsiX12/InterchangeControlHeader.php +++ b/Utils/EDI/AnsiX12/InterchangeControlHeader.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12; @@ -207,7 +207,7 @@ class InterchangeControlHeader public function setAuthorizationInformationQualifier(int $qualifer) /* : void */ { - if($qualifer > 99) { + if ($qualifer > 99) { throw new \Exception(); } @@ -221,7 +221,7 @@ class InterchangeControlHeader public function setAuthorizationInformation(string $information) /* : void */ { - if(strlen($information) > 10) { + if (strlen($information) > 10) { throw new \Exception(); } @@ -235,7 +235,7 @@ class InterchangeControlHeader public function setSecurityInformationQualifer(int $qualifer) /* : void */ { - if($qualifer > 99) { + if ($qualifer > 99) { throw new \Exception(); } @@ -249,7 +249,7 @@ class InterchangeControlHeader public function setSecurityInformation(string $information) /* : void */ { - if(strlen($information) > 10) { + if (strlen($information) > 10) { throw new \Exception(); } @@ -263,7 +263,7 @@ class InterchangeControlHeader public function setInterchangeIdQualifier(int $qualifer) /* : void */ { - if($qualifer > 99) { + if ($qualifer > 99) { throw new \Exception(); } @@ -278,7 +278,7 @@ class InterchangeControlHeader public function setInterchangeSender(string $information) /* : void */ { - if(strlen($information) > 15) { + if (strlen($information) > 15) { throw new \Exception(); } @@ -292,7 +292,7 @@ class InterchangeControlHeader public function setInterchangeReceiver(string $information) /* : void */ { - if(strlen($information) > 15) { + if (strlen($information) > 15) { throw new \Exception(); } @@ -321,7 +321,7 @@ class InterchangeControlHeader public function setInterchangeControlStandardId(string $id) /* : void */ { - if(strlen($id) !== 1) { + if (strlen($id) !== 1) { throw new \Exception(); } @@ -335,7 +335,7 @@ class InterchangeControlHeader public function setInterchangeControlVersionNumber(int $version) /* : void */ { - if($version > 99999) { + if ($version > 99999) { throw new \Exception(); } @@ -349,7 +349,7 @@ class InterchangeControlHeader public function setInterchangeControlNumber(int $number) /* : void */ { - if($number > 999999999) { + if ($number > 999999999) { throw new \Exception(); } @@ -373,7 +373,7 @@ class InterchangeControlHeader public function setUsageUndicator(string $id) /* : void */ { - if(strlen($id) !== 1) { + if (strlen($id) !== 1) { throw new \Exception(); } diff --git a/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850.php b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850.php index aa115c032..bc0e48578 100644 --- a/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850.php +++ b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12\Purchase\PurchaseOrder; diff --git a/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Detail.php b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Detail.php index 2cdade6a8..707676331 100644 --- a/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Detail.php +++ b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Detail.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12\Purchase\PurchaseOrder; diff --git a/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Heading.php b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Heading.php index 71b63bd8f..029d8437b 100644 --- a/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Heading.php +++ b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Heading.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12\Purchase; diff --git a/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Summary.php b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Summary.php index 9eb92e10f..1da11db54 100644 --- a/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Summary.php +++ b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/EDI850Summary.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12\Purchase\PurchaseOrder; diff --git a/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/TransactionSetHeader.php b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/TransactionSetHeader.php index 7c0bef37c..1cf09d535 100644 --- a/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/TransactionSetHeader.php +++ b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/TransactionSetHeader.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\AnsiX12\Purchase\PurchaseOrder; @@ -49,7 +49,7 @@ class TransactionSetHeader public function setTransactionSetControlNumber(string $number) /* : void */ { - if(strlen($number) < 4 || strlen($number) > 9) { + if (strlen($number) < 4 || strlen($number) > 9) { throw new \Exception(); } diff --git a/Utils/EDI/Edifact/Components/BGM.php b/Utils/EDI/Edifact/Components/BGM.php index f3f8fb7fa..6dea4f4c1 100644 --- a/Utils/EDI/Edifact/Components/BGM.php +++ b/Utils/EDI/Edifact/Components/BGM.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\Edifact\Components; diff --git a/Utils/EDI/Edifact/Components/UNH.php b/Utils/EDI/Edifact/Components/UNH.php index 12d885b98..abac22a4c 100644 --- a/Utils/EDI/Edifact/Components/UNH.php +++ b/Utils/EDI/Edifact/Components/UNH.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\Edifact\Components; diff --git a/Utils/EDI/Edifact/INVOIC.php b/Utils/EDI/Edifact/INVOIC.php index 9361d2eb0..5100daae9 100644 --- a/Utils/EDI/Edifact/INVOIC.php +++ b/Utils/EDI/Edifact/INVOIC.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\EDI\Edifact; @@ -29,9 +29,9 @@ use phpOMS\Utils\EDI\Edifact\Components\BGM; */ class INVOIC { - private $unh = null; + private $unh = null; - private $bgm = null; + private $bgm = null; public function __construct() { diff --git a/Utils/Encoding/Caesar.php b/Utils/Encoding/Caesar.php index bcb44d23b..477bbd770 100644 --- a/Utils/Encoding/Caesar.php +++ b/Utils/Encoding/Caesar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Encoding; @@ -85,7 +85,7 @@ class Caesar $ascii = ord($raw[$i]) - ord($key[$j]); if ($ascii < self::LIMIT_LOWER) { - $ascii = self::LIMIT_UPPER + ($ascii - self::LIMIT_LOWER) ; + $ascii = self::LIMIT_UPPER + ($ascii - self::LIMIT_LOWER); } $result .= chr($ascii); diff --git a/Utils/Encoding/EncodingInterface.php b/Utils/Encoding/EncodingInterface.php index 50eca9533..885318197 100644 --- a/Utils/Encoding/EncodingInterface.php +++ b/Utils/Encoding/EncodingInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Encoding; diff --git a/Utils/Encoding/Gray.php b/Utils/Encoding/Gray.php index 449f010f5..5f5bf131c 100644 --- a/Utils/Encoding/Gray.php +++ b/Utils/Encoding/Gray.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Encoding; diff --git a/Utils/Encoding/Huffman/Dictionary.php b/Utils/Encoding/Huffman/Dictionary.php index 6af369bec..11eec757c 100644 --- a/Utils/Encoding/Huffman/Dictionary.php +++ b/Utils/Encoding/Huffman/Dictionary.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Encoding\Huffman; diff --git a/Utils/Encoding/Huffman/Huffman.php b/Utils/Encoding/Huffman/Huffman.php index 165879c0d..611b47a64 100644 --- a/Utils/Encoding/Huffman/Huffman.php +++ b/Utils/Encoding/Huffman/Huffman.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Encoding\Huffman; diff --git a/Utils/Encoding/XorEncoding.php b/Utils/Encoding/XorEncoding.php index e34df4c3f..3495310ef 100644 --- a/Utils/Encoding/XorEncoding.php +++ b/Utils/Encoding/XorEncoding.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Encoding; diff --git a/Utils/Excel/Excel.php b/Utils/Excel/Excel.php index 242a5aa3c..ba19f433b 100644 --- a/Utils/Excel/Excel.php +++ b/Utils/Excel/Excel.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Excel; diff --git a/Utils/Git/Author.php b/Utils/Git/Author.php index 9d8c91b87..bad0a548f 100644 --- a/Utils/Git/Author.php +++ b/Utils/Git/Author.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Git; diff --git a/Utils/Git/Branch.php b/Utils/Git/Branch.php index b19c63367..8be723793 100644 --- a/Utils/Git/Branch.php +++ b/Utils/Git/Branch.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Git; diff --git a/Utils/Git/Commit.php b/Utils/Git/Commit.php index 2248e97c2..2dfc95f9a 100644 --- a/Utils/Git/Commit.php +++ b/Utils/Git/Commit.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Git; diff --git a/Utils/Git/Git.php b/Utils/Git/Git.php index 9b7cbcc6c..84fc33632 100644 --- a/Utils/Git/Git.php +++ b/Utils/Git/Git.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Git; diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 6f2be2d1f..170ce1a99 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Git; diff --git a/Utils/Git/Tag.php b/Utils/Git/Tag.php index c850f8c1d..5f6fbd12b 100644 --- a/Utils/Git/Tag.php +++ b/Utils/Git/Tag.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Git; diff --git a/Utils/IO/Csv/CsvDatabaseMapper.php b/Utils/IO/Csv/CsvDatabaseMapper.php index 52ad106ff..f88e8afea 100644 --- a/Utils/IO/Csv/CsvDatabaseMapper.php +++ b/Utils/IO/Csv/CsvDatabaseMapper.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Csv; diff --git a/Utils/IO/Csv/CsvInterface.php b/Utils/IO/Csv/CsvInterface.php index f18ce1399..ec66bbb02 100644 --- a/Utils/IO/Csv/CsvInterface.php +++ b/Utils/IO/Csv/CsvInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Csv { diff --git a/Utils/IO/Csv/CsvSettings.php b/Utils/IO/Csv/CsvSettings.php index 2e06387be..7b44f5b7f 100644 --- a/Utils/IO/Csv/CsvSettings.php +++ b/Utils/IO/Csv/CsvSettings.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Csv; diff --git a/Utils/IO/Excel/ExcelDatabaseMapper.php b/Utils/IO/Excel/ExcelDatabaseMapper.php index 26f7cdfe2..327b56282 100644 --- a/Utils/IO/Excel/ExcelDatabaseMapper.php +++ b/Utils/IO/Excel/ExcelDatabaseMapper.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Excel; diff --git a/Utils/IO/Excel/ExcelInterface.php b/Utils/IO/Excel/ExcelInterface.php index 9d871a5b6..1be1037d2 100644 --- a/Utils/IO/Excel/ExcelInterface.php +++ b/Utils/IO/Excel/ExcelInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Excel; diff --git a/Utils/IO/ExchangeInterface.php b/Utils/IO/ExchangeInterface.php index 21b16ad88..736906052 100644 --- a/Utils/IO/ExchangeInterface.php +++ b/Utils/IO/ExchangeInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO; diff --git a/Utils/IO/IODatabaseMapper.php b/Utils/IO/IODatabaseMapper.php index eb3eeed37..492bbfcb6 100644 --- a/Utils/IO/IODatabaseMapper.php +++ b/Utils/IO/IODatabaseMapper.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO; diff --git a/Utils/IO/Json/InvalidJsonException.php b/Utils/IO/Json/InvalidJsonException.php index 53aa67fef..5367845b2 100644 --- a/Utils/IO/Json/InvalidJsonException.php +++ b/Utils/IO/Json/InvalidJsonException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Json; @@ -31,7 +31,7 @@ class InvalidJsonException extends \UnexpectedValueException * * @param string $message Exception message * @param int $code Exception code - * @param \Exception Previous exception + * @param \Exception $previous Previous exception * * @since 1.0.0 */ diff --git a/Utils/IO/Json/JsonInterface.php b/Utils/IO/Json/JsonInterface.php index d1bb6d1a5..68b7a1238 100644 --- a/Utils/IO/Json/JsonInterface.php +++ b/Utils/IO/Json/JsonInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Json; diff --git a/Utils/IO/Pdf/PdfInterface.php b/Utils/IO/Pdf/PdfInterface.php index 64d278a15..8480ec37b 100644 --- a/Utils/IO/Pdf/PdfInterface.php +++ b/Utils/IO/Pdf/PdfInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Pdf; diff --git a/Utils/IO/Zip/ArchiveInterface.php b/Utils/IO/Zip/ArchiveInterface.php index ecf949276..cd4e41640 100644 --- a/Utils/IO/Zip/ArchiveInterface.php +++ b/Utils/IO/Zip/ArchiveInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Zip; /** * Archive interface diff --git a/Utils/IO/Zip/Gz.php b/Utils/IO/Zip/Gz.php index 8dbc19300..23a4ab6fe 100644 --- a/Utils/IO/Zip/Gz.php +++ b/Utils/IO/Zip/Gz.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Zip; /** * Zip class for handling zip files. @@ -36,12 +36,12 @@ class Gz implements ArchiveInterface return false; } - if(($gz = gzopen($destination, 'w')) === false) { + if (($gz = gzopen($destination, 'w')) === false) { return false; } $src = fopen($source, 'r'); - while(!feof($src)) { + while (!feof($src)) { gzwrite($gz, fread($src, 4096)); } @@ -60,7 +60,7 @@ class Gz implements ArchiveInterface return false; } - if(($gz = gzopen($source, 'w')) === false) { + if (($gz = gzopen($source, 'w')) === false) { return false; } diff --git a/Utils/IO/Zip/Tar.php b/Utils/IO/Zip/Tar.php index 1bbcf4890..993361dca 100644 --- a/Utils/IO/Zip/Tar.php +++ b/Utils/IO/Zip/Tar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Zip; /** * Zip class for handling zip files. diff --git a/Utils/IO/Zip/TarGz.php b/Utils/IO/Zip/TarGz.php index dc4f2ca88..8bbfd0014 100644 --- a/Utils/IO/Zip/TarGz.php +++ b/Utils/IO/Zip/TarGz.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Zip; /** * Zip class for handling zip files. @@ -31,7 +31,7 @@ class TarGz implements ArchiveInterface */ public static function pack($source, string $destination, bool $overwrite = true) : bool { - if(!Tar::pack($source, $destination . '.tmp', $overwrite)) { + if (!Tar::pack($source, $destination . '.tmp', $overwrite)) { return false; } @@ -46,7 +46,7 @@ class TarGz implements ArchiveInterface */ public static function unpack(string $source, string $destination) : bool { - if(!Gz::unpack($source, $destination . '.tmp')) { + if (!Gz::unpack($source, $destination . '.tmp')) { return false; } diff --git a/Utils/IO/Zip/Zip.php b/Utils/IO/Zip/Zip.php index 95640c8c6..fd8b1f5ae 100644 --- a/Utils/IO/Zip/Zip.php +++ b/Utils/IO/Zip/Zip.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\IO\Zip; @@ -90,7 +90,7 @@ class Zip implements ArchiveInterface */ public static function unpack(string $source, string $destination) : bool { - if(!file_exists($source)) { + if (!file_exists($source)) { return false; } diff --git a/Utils/ImageUtils.php b/Utils/ImageUtils.php index 0ef014db6..dedb6b480 100644 --- a/Utils/ImageUtils.php +++ b/Utils/ImageUtils.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils; diff --git a/Utils/JobQueue/Job.php b/Utils/JobQueue/Job.php index 50a286a96..350100bbd 100644 --- a/Utils/JobQueue/Job.php +++ b/Utils/JobQueue/Job.php @@ -12,7 +12,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\JobQueue; diff --git a/Utils/JobQueue/JobQueue.php b/Utils/JobQueue/JobQueue.php index 0ac7b16d0..ca6848413 100644 --- a/Utils/JobQueue/JobQueue.php +++ b/Utils/JobQueue/JobQueue.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\JobQueue; @@ -91,12 +91,7 @@ class JobQueue fclose(STDOUT); fclose(STDERR); - function shutdown() - { - posix_kill(posix_getpid(), SIGHUP); - } - - register_shutdown_function('shutdown'); + register_shutdown_function(function() { posix_kill(posix_getpid(), SIGHUP); }); } public function setRunning(bool $run = true) /* : void */ diff --git a/Utils/JsonBuilder.php b/Utils/JsonBuilder.php index dec4a70b2..bc66ceb60 100644 --- a/Utils/JsonBuilder.php +++ b/Utils/JsonBuilder.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils; diff --git a/Utils/PDF/Pdf.php b/Utils/PDF/Pdf.php index ecbf2965d..da7be765d 100644 --- a/Utils/PDF/Pdf.php +++ b/Utils/PDF/Pdf.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\PDF; diff --git a/Utils/Parser/LaTex/Expressions/Product.php b/Utils/Parser/LaTex/Expressions/Product.php index d86e7600e..7b76c99f9 100644 --- a/Utils/Parser/LaTex/Expressions/Product.php +++ b/Utils/Parser/LaTex/Expressions/Product.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\LaTex\Expressions; diff --git a/Utils/Parser/LaTex/Expressions/Sum.php b/Utils/Parser/LaTex/Expressions/Sum.php index d920c2edb..b1dec906b 100644 --- a/Utils/Parser/LaTex/Expressions/Sum.php +++ b/Utils/Parser/LaTex/Expressions/Sum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\LaTex\Expressions; diff --git a/Utils/Parser/LaTex/Expressions/Trigonometry.php b/Utils/Parser/LaTex/Expressions/Trigonometry.php index f485cec6f..7317287cf 100644 --- a/Utils/Parser/LaTex/Expressions/Trigonometry.php +++ b/Utils/Parser/LaTex/Expressions/Trigonometry.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\LaTex\Expressions; diff --git a/Utils/Parser/LaTex/LaTexParser.php b/Utils/Parser/LaTex/LaTexParser.php index b1e480b27..9468f11c8 100644 --- a/Utils/Parser/LaTex/LaTexParser.php +++ b/Utils/Parser/LaTex/LaTexParser.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\LaTex; diff --git a/Utils/Parser/LaTex/Types/Interval.php b/Utils/Parser/LaTex/Types/Interval.php index 9a1004351..07af2a269 100644 --- a/Utils/Parser/LaTex/Types/Interval.php +++ b/Utils/Parser/LaTex/Types/Interval.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\LaTex\Types; diff --git a/Utils/Parser/LaTex/Types/MathFunction.php b/Utils/Parser/LaTex/Types/MathFunction.php index a78908389..1db797131 100644 --- a/Utils/Parser/LaTex/Types/MathFunction.php +++ b/Utils/Parser/LaTex/Types/MathFunction.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\LaTex\Types; diff --git a/Utils/Parser/LaTex/Types/Variable.php b/Utils/Parser/LaTex/Types/Variable.php index 89f1daa42..8c8d24ae1 100644 --- a/Utils/Parser/LaTex/Types/Variable.php +++ b/Utils/Parser/LaTex/Types/Variable.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\LaTex\Types; diff --git a/Utils/Parser/Markdown/Markdown.php b/Utils/Parser/Markdown/Markdown.php index 846c617b6..e4cc9a136 100644 --- a/Utils/Parser/Markdown/Markdown.php +++ b/Utils/Parser/Markdown/Markdown.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\Markdown; @@ -102,8 +102,8 @@ class Markdown $block = array_keys(self::$blockTypes); $inline = array_keys(self::$inlineTypes); - foreach($lines as $line) { - foreach($line as $character) { + foreach ($lines as $line) { + foreach ($line as $character) { } } diff --git a/Utils/Parser/Php/ArrayParser.php b/Utils/Parser/Php/ArrayParser.php index c16bb72d8..0d63cb5b4 100644 --- a/Utils/Parser/Php/ArrayParser.php +++ b/Utils/Parser/Php/ArrayParser.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\Php; diff --git a/Utils/Parser/Php/ClassParser.php b/Utils/Parser/Php/ClassParser.php index 55e1e8485..2ae53ae41 100644 --- a/Utils/Parser/Php/ClassParser.php +++ b/Utils/Parser/Php/ClassParser.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\Php; diff --git a/Utils/Parser/Php/ClassType.php b/Utils/Parser/Php/ClassType.php index 439e57a20..49fd53eff 100644 --- a/Utils/Parser/Php/ClassType.php +++ b/Utils/Parser/Php/ClassType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\Php; diff --git a/Utils/Parser/Php/FunctionParser.php b/Utils/Parser/Php/FunctionParser.php index 649129e58..454506776 100644 --- a/Utils/Parser/Php/FunctionParser.php +++ b/Utils/Parser/Php/FunctionParser.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\Php; diff --git a/Utils/Parser/Php/MemberParser.php b/Utils/Parser/Php/MemberParser.php index f45cc79af..b82ed9894 100644 --- a/Utils/Parser/Php/MemberParser.php +++ b/Utils/Parser/Php/MemberParser.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\Php; diff --git a/Utils/Parser/Php/Visibility.php b/Utils/Parser/Php/Visibility.php index bb8f9ab18..955911246 100644 --- a/Utils/Parser/Php/Visibility.php +++ b/Utils/Parser/Php/Visibility.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\Parser\Php; diff --git a/Utils/Permutation.php b/Utils/Permutation.php index cdc0efd38..bf2f034db 100644 --- a/Utils/Permutation.php +++ b/Utils/Permutation.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils; diff --git a/Utils/RnG/Address.php b/Utils/RnG/Address.php index 3078e5e99..78da29758 100644 --- a/Utils/RnG/Address.php +++ b/Utils/RnG/Address.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/ArrayRandomize.php b/Utils/RnG/ArrayRandomize.php index 02931e988..a6431ac71 100644 --- a/Utils/RnG/ArrayRandomize.php +++ b/Utils/RnG/ArrayRandomize.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/City.php b/Utils/RnG/City.php index 5f3343a17..557b6999e 100644 --- a/Utils/RnG/City.php +++ b/Utils/RnG/City.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/DateTime.php b/Utils/RnG/DateTime.php index 94dce1cb5..5b5b7b60d 100644 --- a/Utils/RnG/DateTime.php +++ b/Utils/RnG/DateTime.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/DistributionType.php b/Utils/RnG/DistributionType.php index 544296777..9b45890a6 100644 --- a/Utils/RnG/DistributionType.php +++ b/Utils/RnG/DistributionType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/Email.php b/Utils/RnG/Email.php index 0756d51e1..ce5f28ea0 100644 --- a/Utils/RnG/Email.php +++ b/Utils/RnG/Email.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/File.php b/Utils/RnG/File.php index b892b587c..aca4ce7ac 100644 --- a/Utils/RnG/File.php +++ b/Utils/RnG/File.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/Iban.php b/Utils/RnG/Iban.php index 85056b204..dd5c27428 100644 --- a/Utils/RnG/Iban.php +++ b/Utils/RnG/Iban.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/LinearCongruentialGenerator.php b/Utils/RnG/LinearCongruentialGenerator.php index 074452972..01f2016f9 100644 --- a/Utils/RnG/LinearCongruentialGenerator.php +++ b/Utils/RnG/LinearCongruentialGenerator.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; @@ -40,7 +40,7 @@ class LinearCongruentialGenerator */ public static function bsd(int $seed = 0) { - if($seed !== 0) { + if ($seed !== 0) { self::$bsdSeed = $seed; } @@ -58,7 +58,7 @@ class LinearCongruentialGenerator */ public static function msvcrt(int $seed = 0) { - if($seed !== 0) { + if ($seed !== 0) { self::$msvcrtSeed = $seed; } diff --git a/Utils/RnG/Name.php b/Utils/RnG/Name.php index ae64cc0cb..99028bc31 100644 --- a/Utils/RnG/Name.php +++ b/Utils/RnG/Name.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/Numeric.php b/Utils/RnG/Numeric.php index 0696086c9..30b30cffa 100644 --- a/Utils/RnG/Numeric.php +++ b/Utils/RnG/Numeric.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/Phone.php b/Utils/RnG/Phone.php index 128660d93..575e10e51 100644 --- a/Utils/RnG/Phone.php +++ b/Utils/RnG/Phone.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/PostalZip.php b/Utils/RnG/PostalZip.php index bf3919bc3..abea2d753 100644 --- a/Utils/RnG/PostalZip.php +++ b/Utils/RnG/PostalZip.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/StringUtils.php b/Utils/RnG/StringUtils.php index e70c147fd..44fd5322e 100644 --- a/Utils/RnG/StringUtils.php +++ b/Utils/RnG/StringUtils.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/RnG/Text.php b/Utils/RnG/Text.php index dd9b8016d..b4ea5dcc3 100644 --- a/Utils/RnG/Text.php +++ b/Utils/RnG/Text.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\RnG; diff --git a/Utils/StringCompare.php b/Utils/StringCompare.php index 4d471d751..c016d716f 100644 --- a/Utils/StringCompare.php +++ b/Utils/StringCompare.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils; @@ -76,10 +76,10 @@ class StringCompare $bestScore = PHP_INT_MAX; $bestMatch = ''; - foreach($this->dictionary as $word) { + foreach ($this->dictionary as $word) { $score = self::fuzzyMatch($word, $match); - if($score < $bestScore) { + if ($score < $bestScore) { $bestScore = $score; $bestMatch = $word; } @@ -104,17 +104,17 @@ class StringCompare $words2 = preg_split('/[ _-]/', $s2); $total = 0; - foreach($words1 as $word1) { + foreach ($words1 as $word1) { $best = strlen($s2); - foreach($words2 as $word2) { + foreach ($words2 as $word2) { $wordDist = levenshtein($word1, $word2); - if($wordDist < $best) { + if ($wordDist < $best) { $best = $wordDist; } - if($wordDist === 0) { + if ($wordDist === 0) { break; } } diff --git a/Utils/StringUtils.php b/Utils/StringUtils.php index 8b9df87fd..931e5809f 100644 --- a/Utils/StringUtils.php +++ b/Utils/StringUtils.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils; @@ -384,10 +384,10 @@ class StringUtils $l = mb_strlen($input, 'UTF-8'); $unique = []; - for($i = 0; $i < $l; $i++) { + for ($i = 0; $i < $l; $i++) { $char = mb_substr($input, $i, 1, 'UTF-8'); - if(!array_key_exists($char, $unique)) { + if (!array_key_exists($char, $unique)) { $unique[$char] = 0; } diff --git a/Utils/TaskSchedule/Cron.php b/Utils/TaskSchedule/Cron.php index 2f8b9d765..b5a0ee1e1 100644 --- a/Utils/TaskSchedule/Cron.php +++ b/Utils/TaskSchedule/Cron.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\TaskSchedule; diff --git a/Utils/TaskSchedule/CronJob.php b/Utils/TaskSchedule/CronJob.php index d2c58a931..0defe0a0d 100644 --- a/Utils/TaskSchedule/CronJob.php +++ b/Utils/TaskSchedule/CronJob.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\TaskSchedule; diff --git a/Utils/TaskSchedule/Interval.php b/Utils/TaskSchedule/Interval.php index a18d220a0..570bdc503 100644 --- a/Utils/TaskSchedule/Interval.php +++ b/Utils/TaskSchedule/Interval.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\TaskSchedule; diff --git a/Utils/TaskSchedule/InvalidTaskParameterException.php b/Utils/TaskSchedule/InvalidTaskParameterException.php index 8a55a9fd2..245b887d1 100644 --- a/Utils/TaskSchedule/InvalidTaskParameterException.php +++ b/Utils/TaskSchedule/InvalidTaskParameterException.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\TaskSchedule; diff --git a/Utils/TaskSchedule/Schedule.php b/Utils/TaskSchedule/Schedule.php index bb67b820a..754b25ff0 100644 --- a/Utils/TaskSchedule/Schedule.php +++ b/Utils/TaskSchedule/Schedule.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\TaskSchedule; diff --git a/Utils/TaskSchedule/SchedulerAbstract.php b/Utils/TaskSchedule/SchedulerAbstract.php index 8a875680a..0b0edd169 100644 --- a/Utils/TaskSchedule/SchedulerAbstract.php +++ b/Utils/TaskSchedule/SchedulerAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\TaskSchedule; use phpOMS\System\File\PathException; diff --git a/Utils/TaskSchedule/SchedulerFactory.php b/Utils/TaskSchedule/SchedulerFactory.php index ef8b6bd5d..11f6a589a 100644 --- a/Utils/TaskSchedule/SchedulerFactory.php +++ b/Utils/TaskSchedule/SchedulerFactory.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\TaskSchedule; diff --git a/Utils/TaskSchedule/TaskAbstract.php b/Utils/TaskSchedule/TaskAbstract.php index 9ef962f30..f31b5e8d0 100644 --- a/Utils/TaskSchedule/TaskAbstract.php +++ b/Utils/TaskSchedule/TaskAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\TaskSchedule; diff --git a/Utils/TaskSchedule/TaskFactory.php b/Utils/TaskSchedule/TaskFactory.php index ebfba5f41..a9684a71b 100644 --- a/Utils/TaskSchedule/TaskFactory.php +++ b/Utils/TaskSchedule/TaskFactory.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\TaskSchedule; diff --git a/Utils/TaskSchedule/TaskScheduler.php b/Utils/TaskSchedule/TaskScheduler.php index 8dcc8c25e..6ea4aace2 100644 --- a/Utils/TaskSchedule/TaskScheduler.php +++ b/Utils/TaskSchedule/TaskScheduler.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils\TaskSchedule; @@ -104,22 +104,22 @@ class TaskScheduler extends SchedulerAbstract $job->setRun($jobData[8]); $job->setStatus($jobData[3]); - if(DateTime::isValid($jobData[2])) { + if (DateTime::isValid($jobData[2])) { $job->setNextRunTime(new \DateTime($jobData[2])); } - if(DateTime::isValid($jobData[5])) { + if (DateTime::isValid($jobData[5])) { $job->setLastRuntime(new \DateTime($jobData[5])); } $job->setAuthor($jobData[7]); $job->setComment($jobData[10]); - if(DateTime::isValid($jobData[20])) { + if (DateTime::isValid($jobData[20])) { $job->setStart(new \DateTime($jobData[20])); } - if(DateTime::isValid($jobData[21])) { + if (DateTime::isValid($jobData[21])) { $job->setEnd(new \DateTime($jobData[21])); } @@ -137,7 +137,7 @@ class TaskScheduler extends SchedulerAbstract unset($lines[0]); $jobs = []; - foreach($lines as $line) { + foreach ($lines as $line) { $jobs[] = $this->parseJobList(str_getcsv($line)); } @@ -165,12 +165,12 @@ class TaskScheduler extends SchedulerAbstract */ public function getAllByName(string $name, bool $exact = true) : array { - if($exact) { + if ($exact) { $lines = explode("\n", $this->normalize($this->run('/query /v /fo CSV /tn ' . escapeshellarg($name)))); unset($lines[0]); $jobs = []; - foreach($lines as $line) { + foreach ($lines as $line) { $jobs[] = $this->parseJobList(str_getcsv($line)); } } else { @@ -179,10 +179,10 @@ class TaskScheduler extends SchedulerAbstract unset($lines[0]); - foreach($lines as $key => $line) { + foreach ($lines as $key => $line) { $line = str_getcsv($line); - if(strpos($line[1], $name) !== false) { + if (strpos($line[1], $name) !== false) { $jobs[] = $this->parseJobList($line); } } diff --git a/Utils/TestUtils.php b/Utils/TestUtils.php index 4095bbd37..209bb449a 100644 --- a/Utils/TestUtils.php +++ b/Utils/TestUtils.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Utils; /** * Test utils. @@ -41,7 +41,7 @@ class TestUtils { $reflectionClass = new \ReflectionClass(get_class($obj)); - if(!$reflectionClass->hasProperty($name)) { + if (!$reflectionClass->hasProperty($name)) { return false; } @@ -74,7 +74,7 @@ class TestUtils { $reflectionClass = new \ReflectionClass(get_class($obj)); - if(!$reflectionClass->hasProperty($name)) { + if (!$reflectionClass->hasProperty($name)) { return null; } diff --git a/Validation/Barcode/Barcode.php b/Validation/Barcode/Barcode.php index 42433e8f7..ad6d9c432 100644 --- a/Validation/Barcode/Barcode.php +++ b/Validation/Barcode/Barcode.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Barcode; diff --git a/Validation/Barcode/Barcode11.php b/Validation/Barcode/Barcode11.php index 880df57b4..2ab67e42d 100644 --- a/Validation/Barcode/Barcode11.php +++ b/Validation/Barcode/Barcode11.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Barcode; diff --git a/Validation/Barcode/Barcode128.php b/Validation/Barcode/Barcode128.php index 291e2e412..fb2785121 100644 --- a/Validation/Barcode/Barcode128.php +++ b/Validation/Barcode/Barcode128.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Barcode; diff --git a/Validation/Barcode/Barcode25.php b/Validation/Barcode/Barcode25.php index f8d9b9ea0..6d51c8b26 100644 --- a/Validation/Barcode/Barcode25.php +++ b/Validation/Barcode/Barcode25.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Barcode; diff --git a/Validation/Barcode/Barcode39.php b/Validation/Barcode/Barcode39.php index 55699b1ac..dac544c81 100644 --- a/Validation/Barcode/Barcode39.php +++ b/Validation/Barcode/Barcode39.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Barcode; diff --git a/Validation/Barcode/Barcode93.php b/Validation/Barcode/Barcode93.php index 9eda300d3..d107145d4 100644 --- a/Validation/Barcode/Barcode93.php +++ b/Validation/Barcode/Barcode93.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Barcode; diff --git a/Validation/Barcode/BarcodeCodebar.php b/Validation/Barcode/BarcodeCodebar.php index d58afad7d..f56db616e 100644 --- a/Validation/Barcode/BarcodeCodebar.php +++ b/Validation/Barcode/BarcodeCodebar.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Barcode; diff --git a/Validation/Barcode/BarcodeDatamatrix.php b/Validation/Barcode/BarcodeDatamatrix.php index e7858613c..20f9a2e0d 100644 --- a/Validation/Barcode/BarcodeDatamatrix.php +++ b/Validation/Barcode/BarcodeDatamatrix.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Barcode; diff --git a/Validation/Barcode/BarcodeEAN.php b/Validation/Barcode/BarcodeEAN.php index bcd9a4904..ca8524926 100644 --- a/Validation/Barcode/BarcodeEAN.php +++ b/Validation/Barcode/BarcodeEAN.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Barcode; diff --git a/Validation/Barcode/BarcodeMSI.php b/Validation/Barcode/BarcodeMSI.php index 3c9b35285..7a86c22f8 100644 --- a/Validation/Barcode/BarcodeMSI.php +++ b/Validation/Barcode/BarcodeMSI.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Barcode; diff --git a/Validation/Barcode/QrCode.php b/Validation/Barcode/QrCode.php index bb67e095a..7a63a93f6 100644 --- a/Validation/Barcode/QrCode.php +++ b/Validation/Barcode/QrCode.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Barcode; diff --git a/Validation/Base/DateTime.php b/Validation/Base/DateTime.php index 8f0e8cdb8..be45332a3 100644 --- a/Validation/Base/DateTime.php +++ b/Validation/Base/DateTime.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Base; diff --git a/Validation/Finance/BIC.php b/Validation/Finance/BIC.php index 5802fa04c..49e8d17a0 100644 --- a/Validation/Finance/BIC.php +++ b/Validation/Finance/BIC.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Finance; diff --git a/Validation/Finance/CreditCard.php b/Validation/Finance/CreditCard.php index 4ed2c178f..3c83f2fbd 100644 --- a/Validation/Finance/CreditCard.php +++ b/Validation/Finance/CreditCard.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Finance; diff --git a/Validation/Finance/Iban.php b/Validation/Finance/Iban.php index a0479f372..d0cea61f8 100644 --- a/Validation/Finance/Iban.php +++ b/Validation/Finance/Iban.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Finance; diff --git a/Validation/Finance/IbanEnum.php b/Validation/Finance/IbanEnum.php index 3d2f2098e..4337fb8b4 100644 --- a/Validation/Finance/IbanEnum.php +++ b/Validation/Finance/IbanEnum.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Finance; diff --git a/Validation/Finance/IbanErrorType.php b/Validation/Finance/IbanErrorType.php index 9d54d9f6a..61d79860d 100644 --- a/Validation/Finance/IbanErrorType.php +++ b/Validation/Finance/IbanErrorType.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Finance; diff --git a/Validation/ModelValidationTrait.php b/Validation/ModelValidationTrait.php index 3bdc9c26b..6985aae24 100644 --- a/Validation/ModelValidationTrait.php +++ b/Validation/ModelValidationTrait.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation; diff --git a/Validation/Network/Email.php b/Validation/Network/Email.php index 30afa77c2..2ad608efb 100644 --- a/Validation/Network/Email.php +++ b/Validation/Network/Email.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Network; diff --git a/Validation/Network/Hostname.php b/Validation/Network/Hostname.php index cc0ca5c1d..9742dee5a 100644 --- a/Validation/Network/Hostname.php +++ b/Validation/Network/Hostname.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Network; diff --git a/Validation/Network/Ip.php b/Validation/Network/Ip.php index 3289b6872..a30c5a0f4 100644 --- a/Validation/Network/Ip.php +++ b/Validation/Network/Ip.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation\Network; diff --git a/Validation/Validator.php b/Validation/Validator.php index ecb079c71..a4ea575de 100644 --- a/Validation/Validator.php +++ b/Validation/Validator.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation; @@ -39,6 +39,10 @@ final class Validator extends ValidatorAbstract */ public static function isValid($var, array $constraints = null) : bool { + if (!isset($constraints)) { + return true; + } + foreach ($constraints as $callback => $settings) { $callback = StringUtils::endsWith($callback, 'Not') ? substr($callback, 0, -3) : $callback; $valid = self::$callback($var, ...$settings); diff --git a/Validation/ValidatorAbstract.php b/Validation/ValidatorAbstract.php index 2258eca5c..dcf069298 100644 --- a/Validation/ValidatorAbstract.php +++ b/Validation/ValidatorAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation; diff --git a/Validation/ValidatorInterface.php b/Validation/ValidatorInterface.php index 33589fdfb..a7ecbbf13 100644 --- a/Validation/ValidatorInterface.php +++ b/Validation/ValidatorInterface.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Validation; diff --git a/Version/Version.php b/Version/Version.php index 2f5cc2b8d..98ed8a1f9 100644 --- a/Version/Version.php +++ b/Version/Version.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Version; diff --git a/Views/View.php b/Views/View.php index e869ad3de..6235d9d84 100644 --- a/Views/View.php +++ b/Views/View.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Views; @@ -82,12 +82,12 @@ class View extends ViewAbstract * * @since 1.0.0 */ - public function __construct(ApplicationAbstract $app, RequestAbstract $request, ResponseAbstract $response) + public function __construct(ApplicationAbstract $app = null, RequestAbstract $request = null, ResponseAbstract $response = null) { $this->app = $app; $this->request = $request; $this->response = $response; - $this->l11n = $response->getHeader()->getL11n(); + $this->l11n = isset($response) ? $response->getHeader()->getL11n() : null; } /** @@ -145,7 +145,7 @@ class View extends ViewAbstract */ public function addData(string $id, $data) : bool { - if(isset($this->data[$id])) { + if (isset($this->data[$id])) { return false; } diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index c7bb3cbeb..8b8342f69 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -11,7 +11,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -declare(strict_types=1); +declare(strict_types = 1); namespace phpOMS\Views; @@ -175,14 +175,14 @@ abstract class ViewAbstract implements \Serializable /** * Serialize view for rendering. * - * @return string|array + * @return string * * @since 1.0.0 */ public function serialize() { if (empty($this->template)) { - return $this->toArray(); + return json_encode($this->toArray()); } return $this->render(); @@ -215,11 +215,11 @@ abstract class ViewAbstract implements \Serializable * * @param array $data Data to pass to renderer * - * @return array|string + * @return string * * @since 1.0.0 */ - public function render(...$data) + public function render(...$data) : string { $ob = ''; $path = __DIR__ . '/../..' . $this->template . '.tpl.php'; @@ -232,12 +232,12 @@ abstract class ViewAbstract implements \Serializable ob_start(); /** @noinspection PhpIncludeInspection */ $includeData = include $path; - $ob = ob_get_clean(); + $ob = ob_get_clean(); if (is_array($includeData)) { - return $includeData; + return json_encode($includeData); } - } catch(\Throwable $e) { + } catch (\Throwable $e) { $ob = ''; } finally { return $ob;