diff --git a/Account/Account.php b/Account/Account.php index fed37a1ec..1cd90fdaa 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -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)) diff --git a/Algorithm/Knappsack/Backpack.php b/Algorithm/Knappsack/Backpack.php index 67574ef07..f0297f8d2 100644 --- a/Algorithm/Knappsack/Backpack.php +++ b/Algorithm/Knappsack/Backpack.php @@ -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; } diff --git a/ApplicationAbstract.php b/ApplicationAbstract.php index 425a70556..6c106eccf 100644 --- a/ApplicationAbstract.php +++ b/ApplicationAbstract.php @@ -145,7 +145,7 @@ class ApplicationAbstract */ public function __set($name, $value) { - if(!empty($this->$name)) { + if (!empty($this->$name)) { return; } diff --git a/Autoloader.php b/Autoloader.php index dbe58d75e..f981cf889 100644 --- a/Autoloader.php +++ b/Autoloader.php @@ -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/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php b/Business/Finance/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php index 7e05a9634..c2f82e97b 100644 --- a/Business/Finance/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php +++ b/Business/Finance/Forecasting/ExponentialSmoothing/ExponentialSmoothing.php @@ -67,21 +67,21 @@ 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) { @@ -92,23 +92,23 @@ class ExponentialSmoothing } 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,7 +117,7 @@ class ExponentialSmoothing private function dampingSum(float $damping, int $length) : float { - if(abs($damping - 1) < 0.001) { + if (abs($damping - 1) < 0.001) { return $length; } @@ -180,7 +180,7 @@ class ExponentialSmoothing while ($alpha < 1) { $gamma = 0.00; - while($gamma < 1) { + while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); $error = []; $tempForecast = []; @@ -231,7 +231,7 @@ class ExponentialSmoothing while ($alpha < 1) { $gamma = 0.00; - while($gamma < 1) { + while ($gamma < 1) { $gamma_ = $gamma * (1 - $alpha); $error = []; $tempForecast = []; @@ -278,7 +278,7 @@ class ExponentialSmoothing while ($alpha < 1) { $beta = 0.00; - while($beta < 1) { + while ($beta < 1) { $error = []; $tempForecast = []; @@ -334,10 +334,10 @@ 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 = []; $tempForecast = []; @@ -401,10 +401,10 @@ 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 = []; $tempForecast = []; @@ -455,7 +455,7 @@ class ExponentialSmoothing while ($alpha < 1) { $beta = 0.00; - while($beta < 1) { + while ($beta < 1) { $error = []; $tempForecast = []; @@ -510,10 +510,10 @@ 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 = []; $tempForecast = []; @@ -576,10 +576,10 @@ 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 = []; $tempForecast = []; diff --git a/Business/Marketing/NetPromoterScore.php b/Business/Marketing/NetPromoterScore.php index 651c70a83..4f8882567 100644 --- a/Business/Marketing/NetPromoterScore.php +++ b/Business/Marketing/NetPromoterScore.php @@ -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/DataStorage/Cache/CachePool.php b/DataStorage/Cache/CachePool.php index b5d31470d..5d897487c 100644 --- a/DataStorage/Cache/CachePool.php +++ b/DataStorage/Cache/CachePool.php @@ -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/FileCache.php b/DataStorage/Cache/FileCache.php index 1e8545ba6..d2106fe6d 100644 --- a/DataStorage/Cache/FileCache.php +++ b/DataStorage/Cache/FileCache.php @@ -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; } @@ -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; } @@ -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; } @@ -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/Cookie/CookieJar.php b/DataStorage/Cookie/CookieJar.php index d7108e565..8ca3532a6 100644 --- a/DataStorage/Cookie/CookieJar.php +++ b/DataStorage/Cookie/CookieJar.php @@ -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/Database/Connection/MysqlConnection.php b/DataStorage/Database/Connection/MysqlConnection.php index 6be44cabb..2f2a6597d 100644 --- a/DataStorage/Database/Connection/MysqlConnection.php +++ b/DataStorage/Database/Connection/MysqlConnection.php @@ -60,27 +60,27 @@ class MysqlConnection extends ConnectionAbstract { $this->dbdata = isset($dbdata) ? $dbdata : $this->dbdata; - if(!isset($this->dbdata['db'])) { + if (!isset($this->dbdata['db'])) { throw new InvalidConnectionConfigException('db'); } - if(!isset($this->dbdata['host'])) { + if (!isset($this->dbdata['host'])) { throw new InvalidConnectionConfigException('host'); } - if(!isset($this->dbdata['port'])) { + if (!isset($this->dbdata['port'])) { throw new InvalidConnectionConfigException('port'); } - if(!isset($this->dbdata['database'])) { + if (!isset($this->dbdata['database'])) { throw new InvalidConnectionConfigException('database'); } - if(!isset($this->dbdata['login'])) { + if (!isset($this->dbdata['login'])) { throw new InvalidConnectionConfigException('login'); } - if(!isset($this->dbdata['password'])) { + if (!isset($this->dbdata['password'])) { throw new InvalidConnectionConfigException('password'); } diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index c65d75443..c626203e4 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -302,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; } @@ -323,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'); } } @@ -346,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; @@ -990,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); } } @@ -1164,7 +1164,7 @@ class DataMapperAbstract implements DataMapperInterface $objId = self::getObjectId($obj, $reflectionClass); $update = true; - if(empty($objId)) { + if (empty($objId)) { $update = false; self::create($obj, $relations); } @@ -1173,7 +1173,7 @@ class DataMapperAbstract implements DataMapperInterface self::updateHasMany($reflectionClass, $obj, $objId); } - if($update) { + if ($update) { self::updateModel($obj, $objId, $reflectionClass); } @@ -1234,7 +1234,7 @@ class DataMapperAbstract implements DataMapperInterface // already in db if (!empty($primaryKey)) { - if($relations === RelationType::ALL) { + if ($relations === RelationType::ALL) { $objsIds[$key] = $mapper::delete($value); } else { $objsIds[$key] = $primaryKey; @@ -1322,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(); @@ -1373,7 +1373,7 @@ class DataMapperAbstract implements DataMapperInterface $reflectionClass = new \ReflectionClass(get_class($obj)); $objId = self::getObjectId($obj, $reflectionClass); - if(empty($objId)) { + if (empty($objId)) { return null; } @@ -1485,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; } @@ -1521,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; } @@ -1558,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)); @@ -1590,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]); @@ -1627,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)); @@ -1659,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]); @@ -1696,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)); @@ -1728,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]); @@ -1763,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']); } @@ -1836,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(); } @@ -1849,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; } @@ -1860,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(); } @@ -1872,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); } @@ -1905,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(); } @@ -1915,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; } @@ -1944,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(); } @@ -1956,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)); @@ -1967,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); } @@ -1990,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(); } @@ -2002,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)); @@ -2026,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(); } @@ -2049,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(); } @@ -2490,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] = []; } @@ -2562,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 d00fc9191..032ac4c50 100644 --- a/DataStorage/Database/DataMapperBaseAbstract.php +++ b/DataStorage/Database/DataMapperBaseAbstract.php @@ -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/DatabasePool.php b/DataStorage/Database/DatabasePool.php index f6748656a..a2cb74c4b 100644 --- a/DataStorage/Database/DatabasePool.php +++ b/DataStorage/Database/DatabasePool.php @@ -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/Exception/InvalidMapperException.php b/DataStorage/Database/Exception/InvalidMapperException.php index 9cc312591..9a9023031 100644 --- a/DataStorage/Database/Exception/InvalidMapperException.php +++ b/DataStorage/Database/Exception/InvalidMapperException.php @@ -37,7 +37,7 @@ class InvalidMapperException extends \RuntimeException */ 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 f4ce281ba..dade99a6a 100644 --- a/DataStorage/Database/GrammarAbstract.php +++ b/DataStorage/Database/GrammarAbstract.php @@ -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 57770e4e7..9766b4412 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -356,10 +356,10 @@ class Builder extends BuilderAbstract */ public function raw(string $raw) : Builder { - if($this->isReadOnly) { + if ($this->isReadOnly) { $test = strtolower($raw); - if(strpos($test, 'insert') !== false + if (strpos($test, 'insert') !== false || strpos($test, 'update') !== false || strpos($test, 'drop') !== false || strpos($test, 'delete') !== false @@ -523,7 +523,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 +677,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 +840,7 @@ class Builder extends BuilderAbstract */ public function insert(...$columns) : Builder { - if($this->isReadOnly) { + if ($this->isReadOnly) { throw new \Exception(); } @@ -949,7 +949,7 @@ class Builder extends BuilderAbstract */ public function update(...$tables) : Builder { - if($this->isReadOnly) { + if ($this->isReadOnly) { throw new \Exception(); } @@ -968,7 +968,7 @@ class Builder extends BuilderAbstract public function delete() : Builder { - if($this->isReadOnly) { + if ($this->isReadOnly) { throw new \Exception(); } @@ -1099,7 +1099,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 +1119,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 +1130,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/Grammar/Grammar.php b/DataStorage/Database/Query/Grammar/Grammar.php index c1ae46d1b..6b3cf5538 100644 --- a/DataStorage/Database/Query/Grammar/Grammar.php +++ b/DataStorage/Database/Query/Grammar/Grammar.php @@ -270,7 +270,7 @@ class Grammar extends GrammarAbstract { $expression = ''; - if(!$first) { + if (!$first) { $expression = ' ' . strtoupper($element['boolean']) . ' '; } @@ -317,7 +317,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 +420,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/Session/HttpSession.php b/DataStorage/Session/HttpSession.php index 64cfebd59..6844132f8 100644 --- a/DataStorage/Session/HttpSession.php +++ b/DataStorage/Session/HttpSession.php @@ -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/Web/Builder.php b/DataStorage/Web/Builder.php index 274beed4f..31d2e092b 100644 --- a/DataStorage/Web/Builder.php +++ b/DataStorage/Web/Builder.php @@ -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 dc23a99d4..ac7e35e1c 100644 --- a/Dispatcher/Dispatcher.php +++ b/Dispatcher/Dispatcher.php @@ -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 76427d24d..8f9a5fde1 100644 --- a/Event/EventManager.php +++ b/Event/EventManager.php @@ -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/Log/FileLogger.php b/Log/FileLogger.php index 17860e5a2..4be39032c 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -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/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index 9c662391a..fa64ecb55 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -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/Stochastic/NaiveBayesFilter.php b/Math/Stochastic/NaiveBayesFilter.php index 1f946b66d..c45cd3b41 100644 --- a/Math/Stochastic/NaiveBayesFilter.php +++ b/Math/Stochastic/NaiveBayesFilter.php @@ -43,8 +43,8 @@ class NaiveBayesFilter $normalizedDict = $this->normalizeDictionary(); $n = 0.0; - foreach($toMatch as $element) { - if(isset($normalizedDict[$element])) { + foreach ($toMatch as $element) { + if (isset($normalizedDict[$element])) { $n += log(1-$normalizedDict[$element]['match'] / $normalizedDict[$element]['total']) - log($normalizedDict[$element]['match'] / $normalizedDict[$element]['total']); } } diff --git a/Message/Http/Header.php b/Message/Http/Header.php index b98838959..bebc3c445 100644 --- a/Message/Http/Header.php +++ b/Message/Http/Header.php @@ -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/Request.php b/Message/Http/Request.php index 5e30c70cf..9b03f30be 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -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/Response.php b/Message/Http/Response.php index 3eb1e957a..4eccd8cb4 100644 --- a/Message/Http/Response.php +++ b/Message/Http/Response.php @@ -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(); } } @@ -143,7 +143,7 @@ class Response extends ResponseAbstract implements RenderableInterface $types = $this->header->get('Content-Type'); - if(stripos($types[0], MimeType::M_HTML) !== false) { + if (stripos($types[0], MimeType::M_HTML) !== false) { return trim(preg_replace('/(\s{2,}|\n|\t)(?![^<>]*<\/pre>)/', ' ', $render)); } diff --git a/Message/Mail/EmailAbstract.php b/Message/Mail/EmailAbstract.php index 404dc95e1..93fc94ee8 100644 --- a/Message/Mail/EmailAbstract.php +++ b/Message/Mail/EmailAbstract.php @@ -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/RequestAbstract.php b/Message/RequestAbstract.php index 9a3c920e8..7760bd951 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -204,7 +204,7 @@ abstract class RequestAbstract implements MessageInterface */ public function getData($key = null) { - if(!isset($key)) { + if (!isset($key)) { return $this->data; } diff --git a/Module/ModuleFactory.php b/Module/ModuleFactory.php index b2e996862..77d23a67e 100644 --- a/Module/ModuleFactory.php +++ b/Module/ModuleFactory.php @@ -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 10d31af02..ec2e10f36 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -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/PackageManager.php b/Module/PackageManager.php index e678b36d5..8405d642b 100644 --- a/Module/PackageManager.php +++ b/Module/PackageManager.php @@ -106,7 +106,7 @@ class PackageManager */ public function load() /* : void */ { - if(!file_exists($this->extractPath)) { + if (!file_exists($this->extractPath)) { throw new PathException($this->extractPath); } @@ -139,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; } @@ -159,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); } } @@ -179,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); } } @@ -193,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); @@ -211,7 +211,7 @@ class PackageManager */ private function delete($components) { - foreach($components as $component) { + foreach ($components as $component) { LocalStorage::delete($this->basePath . '/' . $component); } } @@ -225,7 +225,7 @@ class PackageManager */ private function execute($components) { - foreach($components as $component) { + foreach ($components as $component) { include $this->basePath . '/' . $component; } } diff --git a/Socket/Client/Client.php b/Socket/Client/Client.php index aed92a327..44ecb23c4 100644 --- a/Socket/Client/Client.php +++ b/Socket/Client/Client.php @@ -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/Stdlib/Collection/Collection.php b/Stdlib/Collection/Collection.php index 85050f7e3..c0ceed2f0 100644 --- a/Stdlib/Collection/Collection.php +++ b/Stdlib/Collection/Collection.php @@ -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 e9aa02039..ce018945d 100644 --- a/Stdlib/Graph/BinaryTree.php +++ b/Stdlib/Graph/BinaryTree.php @@ -87,7 +87,7 @@ class BinaryTree extends Tree */ public function setLeft(Node $base, Node $left) : BinaryTree { - if($this->getLeft($base) === null) { + 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? @@ -110,7 +110,7 @@ class BinaryTree extends Tree */ public function setRight(Node $base, Node $right) /* : void */ { - if($this->getRight($base) === null) { + 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? @@ -145,7 +145,7 @@ class BinaryTree extends Tree */ private function getVerticalOrder(Node $node, int $horizontalDistance = 0, array &$order) { - if(!isset($order[$horizontalDistance])) { + if (!isset($order[$horizontalDistance])) { $order[$horizontalDistance] = []; } @@ -153,11 +153,11 @@ class BinaryTree extends Tree $left = $this->getLeft($node); $right = $this->getRight($node); - if(isset($left)) { + if (isset($left)) { $this->getVerticalOrder($left, $horizontalDistance-1, $order); } - if(isset($right)) { + if (isset($right)) { $this->getVerticalOrder($right, $horizontalDistance+1, $order); } } @@ -175,8 +175,8 @@ class BinaryTree extends Tree $order = []; $this->getVerticalOrder($node, 0, $order); - foreach($order as $level) { - foreach($level as $node) { + foreach ($order as $level) { + foreach ($level as $node) { $callback($node); } } @@ -194,7 +194,7 @@ class BinaryTree extends Tree */ public function isSymmetric(Node $node1 = null, Node $node2 = null) : bool { - if(!isset($node1) && !isset($node2)) { + if (!isset($node1) && !isset($node2)) { return true; } @@ -205,7 +205,7 @@ class BinaryTree extends Tree $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)) { + if (isset($node1, $node2)) { return $this->isSymmetric($left1, $right2) && $this->isSymmetric($right1, $left2); } diff --git a/Stdlib/Graph/Tree.php b/Stdlib/Graph/Tree.php index 8e6421790..f4122359f 100644 --- a/Stdlib/Graph/Tree.php +++ b/Stdlib/Graph/Tree.php @@ -76,14 +76,14 @@ class Tree extends Graph { $currentNode = $node ?? $this->root; - if(!isset($currentNode)) { + if (!isset($currentNode)) { return 0; } $depth = 1; $neighbors = $this->getNeighbors($currentNode); - foreach($neighbors as $neighbor) { + foreach ($neighbors as $neighbor) { $depth = max($depth, $depth + $this->getMaxDepth($neighbor)); } @@ -103,14 +103,14 @@ class Tree extends Graph { $currentNode = $node ?? $this->root; - if(!isset($currentNode)) { + if (!isset($currentNode)) { return 0; } $depth = []; $neighbors = $this->getNeighbors($currentNode); - foreach($neighbors as $neighbor) { + foreach ($neighbors as $neighbor) { $depth[] = $this->getMaxDepth($neighbor); } @@ -169,11 +169,11 @@ class Tree extends Graph $neighbors = $this->getNeighbors($node); $nodes = []; - if($level === 1) { + if ($level === 1) { return $neighbors; } - foreach($neighbors as $neighbor) { + foreach ($neighbors as $neighbor) { array_merge($nodes, $this->getLevelNodes($level, $neighbor)); } @@ -191,14 +191,14 @@ class Tree extends Graph */ public function isFull(int $type) : bool { - if(count($this->edges) % $type !== 0) { + if (count($this->edges) % $type !== 0) { return false; } - foreach($this->nodes as $node) { + foreach ($this->nodes as $node) { $neighbors = count($this->getNeighbors($node)); - if($neighbors !== $type && $neighbors !== 0) { + if ($neighbors !== $type && $neighbors !== 0) { return false; } } @@ -215,14 +215,14 @@ class Tree extends Graph * @since 1.0.0 */ public function preOrder(Node $node, \Closure $callback) { - if(count($this->nodes) === 0) { + if (count($this->nodes) === 0) { return; } $callback($node); $neighbors = $this->getNeighbors($node); - foreach($neighbors as $neighbor) { + foreach ($neighbors as $neighbor) { // todo: get neighbors needs to return in ordered way $this->preOrder($neighbor, $callback); } @@ -237,13 +237,13 @@ class Tree extends Graph * @since 1.0.0 */ public function postOrder(Node $node, \Closure $callback) { - if(count($this->nodes) === 0) { + if (count($this->nodes) === 0) { return; } $neighbors = $this->getNeighbors($node); - foreach($neighbors as $neighbor) { + foreach ($neighbors as $neighbor) { // todo: get neighbors needs to return in ordered way $this->postOrder($neighbor, $callback); } diff --git a/System/File/FileUtils.php b/System/File/FileUtils.php index 291e0a863..396c60f8c 100644 --- a/System/File/FileUtils.php +++ b/System/File/FileUtils.php @@ -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/File.php b/System/File/Ftp/File.php index 1f838e1e9..62ad4700f 100644 --- a/System/File/Ftp/File.php +++ b/System/File/Ftp/File.php @@ -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 83aaa35fd..f49daf22d 100644 --- a/System/File/Ftp/FtpStorage.php +++ b/System/File/Ftp/FtpStorage.php @@ -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 5b17d0879..6675925f5 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -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()); } } @@ -254,7 +254,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,13 +312,13 @@ class Directory extends FileAbstract implements DirectoryInterface throw new PathException($from); } - if(!$overwrite && file_exists($to)) { + 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); } @@ -347,7 +347,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 +400,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 c9511472b..083bbf317 100644 --- a/System/File/Local/File.php +++ b/System/File/Local/File.php @@ -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/LocalStorage.php b/System/File/Local/LocalStorage.php index ebf3d111b..073893799 100644 --- a/System/File/Local/LocalStorage.php +++ b/System/File/Local/LocalStorage.php @@ -38,7 +38,7 @@ class LocalStorage extends StorageAbstract public static function getInstance() : StorageAbstract { - if(!isset(self::$instance)) { + if (!isset(self::$instance)) { self::$instance = new self(); } @@ -183,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); } @@ -195,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); } @@ -207,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); } @@ -227,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); } @@ -239,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); } @@ -251,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); } @@ -263,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/Storage.php b/System/File/Storage.php index e29eaf1dc..66586f2dd 100644 --- a/System/File/Storage.php +++ b/System/File/Storage.php @@ -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'); diff --git a/System/OperatingSystem.php b/System/OperatingSystem.php index 51ca50acb..d7ac33dae 100644 --- a/System/OperatingSystem.php +++ b/System/OperatingSystem.php @@ -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/Uri/Http.php b/Uri/Http.php index 2d937060d..d9480eb82 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -283,7 +283,7 @@ class Http implements UriInterface */ public function getQuery(string $key = null) : string { - if(isset($key)) { + if (isset($key)) { $key = strtolower($key); return $this->query[$key] ?? ''; diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 73ed2b4bf..c00ba0663 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -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; } diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index b5605768d..cec20cd9d 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -176,8 +176,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; } } @@ -197,8 +197,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/EDI/AnsiX12/Component/BIG.php b/Utils/EDI/AnsiX12/Component/BIG.php index 842300216..e8f90f9f6 100644 --- a/Utils/EDI/AnsiX12/Component/BIG.php +++ b/Utils/EDI/AnsiX12/Component/BIG.php @@ -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 f6e563731..bfdad1997 100644 --- a/Utils/EDI/AnsiX12/Component/GS.php +++ b/Utils/EDI/AnsiX12/Component/GS.php @@ -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 ddca24eb1..2d1056d11 100644 --- a/Utils/EDI/AnsiX12/Component/ISA.php +++ b/Utils/EDI/AnsiX12/Component/ISA.php @@ -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 0d8c28983..27ec6ce65 100644 --- a/Utils/EDI/AnsiX12/Component/ST.php +++ b/Utils/EDI/AnsiX12/Component/ST.php @@ -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/FunctionalGroupHeader.php b/Utils/EDI/AnsiX12/FunctionalGroupHeader.php index 1d6b208ef..1c820b29b 100644 --- a/Utils/EDI/AnsiX12/FunctionalGroupHeader.php +++ b/Utils/EDI/AnsiX12/FunctionalGroupHeader.php @@ -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/InterchangeControlHeader.php b/Utils/EDI/AnsiX12/InterchangeControlHeader.php index cb52f6fd9..83759ab45 100644 --- a/Utils/EDI/AnsiX12/InterchangeControlHeader.php +++ b/Utils/EDI/AnsiX12/InterchangeControlHeader.php @@ -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/TransactionSetHeader.php b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/TransactionSetHeader.php index c5b969c4f..1cf09d535 100644 --- a/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/TransactionSetHeader.php +++ b/Utils/EDI/AnsiX12/Purchase/PurchaseOrder/TransactionSetHeader.php @@ -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/IO/Zip/Gz.php b/Utils/IO/Zip/Gz.php index ae16b72f4..23a4ab6fe 100644 --- a/Utils/IO/Zip/Gz.php +++ b/Utils/IO/Zip/Gz.php @@ -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/TarGz.php b/Utils/IO/Zip/TarGz.php index 81d27572b..8bbfd0014 100644 --- a/Utils/IO/Zip/TarGz.php +++ b/Utils/IO/Zip/TarGz.php @@ -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 aef44a533..fd8b1f5ae 100644 --- a/Utils/IO/Zip/Zip.php +++ b/Utils/IO/Zip/Zip.php @@ -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/Parser/Markdown/Markdown.php b/Utils/Parser/Markdown/Markdown.php index a75c0aa00..e4cc9a136 100644 --- a/Utils/Parser/Markdown/Markdown.php +++ b/Utils/Parser/Markdown/Markdown.php @@ -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/RnG/LinearCongruentialGenerator.php b/Utils/RnG/LinearCongruentialGenerator.php index 0edbc6fd9..01f2016f9 100644 --- a/Utils/RnG/LinearCongruentialGenerator.php +++ b/Utils/RnG/LinearCongruentialGenerator.php @@ -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/StringCompare.php b/Utils/StringCompare.php index 5918d4e1f..c016d716f 100644 --- a/Utils/StringCompare.php +++ b/Utils/StringCompare.php @@ -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 168164de3..d3b01b0e4 100644 --- a/Utils/StringUtils.php +++ b/Utils/StringUtils.php @@ -387,7 +387,7 @@ class StringUtils 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/TaskScheduler.php b/Utils/TaskSchedule/TaskScheduler.php index 407e865c0..6ea4aace2 100644 --- a/Utils/TaskSchedule/TaskScheduler.php +++ b/Utils/TaskSchedule/TaskScheduler.php @@ -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 08a49e23f..209bb449a 100644 --- a/Utils/TestUtils.php +++ b/Utils/TestUtils.php @@ -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/Validator.php b/Validation/Validator.php index 82d54bcaa..a4ea575de 100644 --- a/Validation/Validator.php +++ b/Validation/Validator.php @@ -39,7 +39,7 @@ final class Validator extends ValidatorAbstract */ public static function isValid($var, array $constraints = null) : bool { - if(!isset($constraints)) { + if (!isset($constraints)) { return true; } diff --git a/Views/View.php b/Views/View.php index 5ce7ca623..4376f04db 100644 --- a/Views/View.php +++ b/Views/View.php @@ -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; }