More codestyle fixes

This commit is contained in:
Dennis Eichhorn 2018-01-31 22:05:15 +01:00
parent 51cd98b1a7
commit f1288ebc03
98 changed files with 1288 additions and 1199 deletions

View File

@ -166,10 +166,10 @@ class Account implements ArrayableInterface, \JsonSerializable
*/
public function __construct(int $id = 0)
{
$this->createdAt = new \DateTime('now');
$this->createdAt = new \DateTime('now');
$this->lastActive = new \DateTime('now');
$this->id = $id;
$this->l11n = new NullLocalization();
$this->id = $id;
$this->l11n = new NullLocalization();
}
/**
@ -329,7 +329,8 @@ class Account implements ArrayableInterface, \JsonSerializable
&& ($p->getType() === $type || $p->getType() === null || !isset($type))
&& ($p->getElement() === $element || $p->getElement() === null || !isset($element))
&& ($p->getComponent() === $component || $p->getComponent() === null || !isset($component))
&& ($p->getPermission() | $permission) === $p->getPermission()) {
&& ($p->getPermission() | $permission) === $p->getPermission()
) {
return true;
}
}

View File

@ -63,4 +63,4 @@ class Depreciation
public static function getGeometicProgressivDepreciationResidualInT(float $start, float $residual, int $duration, int $t) : float
{
}
}
}

View File

@ -24,6 +24,9 @@ use phpOMS\Math\Matrix\Exception\InvalidDimensionException;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
class FinanceFormulas
{

View File

@ -16,4 +16,4 @@ namespace phpOMS\Business\Finance\Forecasting;
class AR
{
}
}

View File

@ -16,4 +16,4 @@ namespace phpOMS\Business\Finance\Forecasting;
class ARCH
{
}
}

View File

@ -18,11 +18,12 @@ use phpOMS\Math\Statistic\Average;
class ARIMA
{
private $data = [];
private $order = 0;
public function __construct(array $data, int $order = 12)
{
$this->data = $data;
$this->data = $data;
$this->order = $order;
if ($order !== 12 && $order !== 4) {
@ -161,4 +162,4 @@ class ARIMA
return $data;
}
}
}

View File

@ -231,4 +231,4 @@ class ClassicalDecomposition
return $remainderComponent;
}
}
}

View File

@ -0,0 +1,33 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @package Framework
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types = 1);
namespace phpOMS\Business\Finance\Forecasting\ExponentialSmoothing;
use phpOMS\Stdlib\Base\Enum;
/**
* Smoothing enum.
*
* @package Framework
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
abstract class ErrorType extends Enum
{
/* public */ const ALL = 0;
/* public */ const NONE = 1;
/* public */ const ADDITIVE = 2;
/* public */ const MULTIPLICATIVE = 4;
}

View File

@ -109,4 +109,4 @@ class ExponentialSmoothing
public function getMMM()
{
}
}
}

View File

@ -26,8 +26,8 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class SeasonalType extends Enum
{
/* public */ const ALL = 0;
/* public */ const NONE = 1;
/* public */ const ADDITIVE = 2;
/* public */ const ALL = 0;
/* public */ const NONE = 1;
/* public */ const ADDITIVE = 2;
/* public */ const MULTIPLICATIVE = 4;
}

View File

@ -26,8 +26,8 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class TrendType extends Enum
{
/* public */ const ALL = 0;
/* public */ const NONE = 1;
/* public */ const ADDITIVE = 2;
/* public */ const ALL = 0;
/* public */ const NONE = 1;
/* public */ const ADDITIVE = 2;
/* public */ const MULTIPLICATIVE = 4;
}

View File

@ -17,4 +17,3 @@ class MA
{
}

View File

@ -17,4 +17,3 @@ class NAR
{
}

View File

@ -17,4 +17,3 @@ class NMA
{
}

View File

@ -17,4 +17,3 @@ class SARIMA
{
}

View File

@ -21,6 +21,9 @@ namespace phpOMS\Business\Finance;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
class Loan
{

View File

@ -50,4 +50,4 @@ class Lorenzkurve
return 2 * $sum1 / ($n * $sum2) - ($n + 1) / $n;
}
}
}

View File

@ -21,6 +21,9 @@ namespace phpOMS\Business\Finance;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
class StockBonds
{

View File

@ -24,7 +24,8 @@ namespace phpOMS\Business\Marketing;
* @link http://website.orange-management.de
* @since 1.0.0
*/
class Metrics {
class Metrics
{
/**
* Calculate customer retention
*
@ -42,4 +43,4 @@ class Metrics {
{
return ($ce - $cn) / $cs;
}
}
}

View File

@ -25,7 +25,8 @@ namespace phpOMS\Business\Marketing;
* @link http://website.orange-management.de
* @since 1.0.0
*/
class NetPromoterScore {
class NetPromoterScore
{
/**
* Score values
*
@ -39,7 +40,8 @@ class NetPromoterScore {
*
* @since 1.0.0
*/
public function __construct() {
public function __construct()
{
}
@ -147,4 +149,4 @@ class NetPromoterScore {
return $count;
}
}
}

View File

@ -24,7 +24,8 @@ namespace phpOMS\Business\Programming;
* @link http://website.orange-management.de
* @since 1.0.0
*/
class Metrics {
class Metrics
{
/**
* Calculate ABC metric score
*
@ -54,9 +55,11 @@ class Metrics {
* @return int
*
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
*/
public static function CRAP(int $complexity, float $coverage) : int
{
return (int) ($complexity ** 2 * (1 - $coverage) ** 3 + $complexity);
}
}
}

View File

@ -25,7 +25,8 @@ namespace phpOMS\Business\Sales;
* @link http://website.orange-management.de
* @since 1.0.0
*/
class MarketShareEstimation {
class MarketShareEstimation
{
/**
* Calculate rank (r) based on market share (m)
*

View File

@ -71,5 +71,4 @@ interface OptionsInterface
* @since 1.0.0
*/
public function getOption($key);
}

View File

@ -135,7 +135,7 @@ abstract class SettingsAbstract implements OptionsInterface
if ($store) {
foreach($this->options as $key => $option) {
$query = new Builder($this->connection);
$sql = $query->update($this->connection->prefix . static::$table)
$sql = $query->update($this->connection->prefix . static::$table)
->set([static::$columns[1] => $option])
->where(static::$columns[0], '=', $key)
->toSql();

View File

@ -35,5 +35,4 @@ interface ArrayableInterface
* @since 1.0.0
*/
public function toArray() : array;
}

View File

@ -36,5 +36,4 @@ interface RenderableInterface
* @since 1.0.0
*/
public function render() : string;
}

View File

@ -13,6 +13,7 @@
declare(strict_types = 1);
namespace phpOMS\DataStorage\Cache;
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
/**
@ -139,5 +140,4 @@ interface CacheInterface
* @since 1.0.0
*/
public function getThreshold() : int;
}

View File

@ -59,7 +59,7 @@ class CachePool implements OptionsInterface
*
* @since 1.0.0
*/
public function add(string $key = 'core', CacheInterface $cache) : bool
public function add(string $key, CacheInterface $cache) : bool
{
if (isset($this->pool[$key])) {
return false;

View File

@ -28,7 +28,7 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class CacheStatus extends Enum
{
/* public */ const ACTIVE = 0;
/* public */ const ACTIVE = 0;
/* public */ const INACTIVE = 1;
/* public */ const ERROR = 2;
/* public */ const ERROR = 2;
}

View File

@ -28,11 +28,11 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class CacheType extends Enum
{
/* public */ const _INT = 0; /* Data is integer */
/* public */ const _STRING = 1; /* Data is string */
/* public */ const _ARRAY = 2; /* Data is array */
/* public */ const _SERIALIZABLE = 3; /* Data is object */
/* public */ const _FLOAT = 4; /* Data is float */
/* public */ const _BOOL = 5; /* Data is bool */
/* public */ const _INT = 0; /* Data is integer */
/* public */ const _STRING = 1; /* Data is string */
/* public */ const _ARRAY = 2; /* Data is array */
/* public */ const _SERIALIZABLE = 3; /* Data is object */
/* public */ const _FLOAT = 4; /* Data is float */
/* public */ const _BOOL = 5; /* Data is bool */
/* public */ const _JSONSERIALIZABLE = 6;
}

View File

@ -383,8 +383,7 @@ class FileCache implements CacheInterface
foreach ($dir as $file) {
if ($file instanceof File) {
$created = $file->getCreatedAt()->getTimestamp();
if (
($expire >= 0 && $created + $expire < $now)
if (($expire >= 0 && $created + $expire < $now)
|| ($expire < 0 && $created + $this->getExpire($file->getContent()) < $now)
) {
File::delete($file->getPath());

View File

@ -45,6 +45,8 @@ class CookieJar
* Constructor.
*
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function __construct()
{

View File

@ -127,5 +127,4 @@ interface DataMapperInterface
* @since 1.0.0
*/
public static function get($primaryKey);
}

View File

@ -55,10 +55,8 @@ class ConnectionFactory
switch ($dbdata['db']) {
case DatabaseType::MYSQL:
return new MysqlConnection($dbdata);
break;
case DatabaseType::SQLSRV:
return new SqlServerConnection($dbdata);
break;
default:
throw new \InvalidArgumentException('Database "' . $dbdata['db'] . '" is not supported.');
}

View File

@ -17,4 +17,4 @@ namespace phpOMS\DataStorage\Database\Connection;
abstract class PostgresConnection extends \Exception
{
}
}

View File

@ -70,7 +70,7 @@ class DataMapperAbstract implements DataMapperInterface
* @var string
* @since 1.0.0
*/
protected static $language_field = '';
protected static $languageField = '';
/**
* Columns.
@ -2129,8 +2129,8 @@ class DataMapperAbstract implements DataMapperInterface
$query->orderBy(static::$table . '.' . static::$columns[static::$primaryField]['name'], 'DESC');
}
if (!empty(self::$language_field) && !empty($lang)) {
$query->where(static::$table . '.' . static::$language_field, '=', $lang, 'AND');
if (!empty(self::$languageField) && !empty($lang)) {
$query->where(static::$table . '.' . static::$languageField, '=', $lang, 'AND');
}
$sth = self::$db->con->prepare($query->toSql());
@ -2392,8 +2392,8 @@ class DataMapperAbstract implements DataMapperInterface
{
$query = self::getQuery();
if (!empty(self::$language_field) && !empty($lang)) {
$query->where(static::$table . '.' . static::$language_field, '=', $lang, 'AND');
if (!empty(self::$languageField) && !empty($lang)) {
$query->where(static::$table . '.' . static::$languageField, '=', $lang, 'AND');
}
$sth = self::$db->con->prepare($query->toSql());

View File

@ -55,7 +55,7 @@ class DatabasePool
*
* @since 1.0.0
*/
public function add(string $key = 'core', ConnectionAbstract $db) : bool
public function add(string $key, ConnectionAbstract $db) : bool
{
if (isset($this->pool[$key])) {
return false;

View File

@ -28,9 +28,9 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class DatabaseType extends Enum
{
/* public */ const MYSQL = 'mysql'; /* MySQL */
/* public */ const SQLITE = 'sqlite'; /* SQLITE */
/* public */ const PGSQL = 2; /* PostgreSQL */
/* public */ const ORACLE = 3; /* Oracle */
/* public */ const SQLSRV = 'mssql'; /* Microsoft SQL Server */
/* public */ const MYSQL = 'mysql'; /* MySQL */
/* public */ const SQLITE = 'sqlite'; /* SQLITE */
/* public */ const PGSQL = 2; /* PostgreSQL */
/* public */ const ORACLE = 3; /* Oracle */
/* public */ const SQLSRV = 'mssql'; /* Microsoft SQL Server */
}

View File

@ -13,6 +13,7 @@
declare(strict_types = 1);
namespace phpOMS\DataStorage\Database\Query\Grammar;
use phpOMS\DataStorage\Database\Query\Builder;
/**

View File

@ -13,6 +13,7 @@
declare(strict_types = 1);
namespace phpOMS\DataStorage\Database\Query\Grammar;
use phpOMS\DataStorage\Database\Query\Builder;
/**

View File

@ -13,6 +13,7 @@
declare(strict_types = 1);
namespace phpOMS\DataStorage\Database\Query\Grammar;
use phpOMS\DataStorage\Database\Query\Builder;
/**

View File

@ -13,6 +13,7 @@
declare(strict_types = 1);
namespace phpOMS\DataStorage\Database\Query\Grammar;
use phpOMS\DataStorage\Database\Query\Builder;
/**

View File

@ -13,6 +13,7 @@
declare(strict_types = 1);
namespace phpOMS\DataStorage\Database\Query\Grammar;
use phpOMS\DataStorage\Database\Query\Builder;
/**

View File

@ -26,15 +26,15 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class JoinType extends Enum
{
/* public */ const JOIN = 'JOIN';
/* public */ const LEFT_JOIN = 'LEFT JOIN';
/* public */ const LEFT_OUTER_JOIN = 'LEFT OUTER JOIN';
/* public */ const LEFT_INNER_JOIN = 'LEFT INNER JOIN';
/* public */ const RIGHT_JOIN = 'RIGHT JOIN';
/* public */ const JOIN = 'JOIN';
/* public */ const LEFT_JOIN = 'LEFT JOIN';
/* public */ const LEFT_OUTER_JOIN = 'LEFT OUTER JOIN';
/* public */ const LEFT_INNER_JOIN = 'LEFT INNER JOIN';
/* public */ const RIGHT_JOIN = 'RIGHT JOIN';
/* public */ const RIGHT_OUTER_JOIN = 'RIGHT OUTER JOIN';
/* public */ const RIGHT_INNER_JOIN = 'RIGHT INNER JOIN';
/* public */ const OUTER_JOIN = 'OUTER JOIN';
/* public */ const INNER_JOIN = 'INNER JOIN';
/* public */ const CROSS_JOIN = 'CROSS JOIN';
/* public */ const FULL_OUTER_JOIN = 'FULL OUTER JOIN';
/* public */ const OUTER_JOIN = 'OUTER JOIN';
/* public */ const INNER_JOIN = 'INNER JOIN';
/* public */ const CROSS_JOIN = 'CROSS JOIN';
/* public */ const FULL_OUTER_JOIN = 'FULL OUTER JOIN';
}

View File

@ -31,5 +31,5 @@ abstract class QueryType extends Enum
/* public */ const UPDATE = 2;
/* public */ const DELETE = 3;
/* public */ const RANDOM = 4;
/* public */ const RAW = 5;
/* public */ const RAW = 5;
}

View File

@ -46,16 +46,16 @@ class Builder extends BuilderAbstract
public function select(...$table) /* : void */
{
$this->type = QueryType::SELECT;
$this->type = QueryType::SELECT;
$this->table += $table;
$this->table = array_unique($this->table);
$this->table = array_unique($this->table);
}
public function drop(...$table)
{
$this->type = QueryType::DROP;
$this->type = QueryType::DROP;
$this->drop += $table;
$this->drop = array_unique($this->drop);
$this->drop = array_unique($this->drop);
}
public function create(string $table)

View File

@ -25,6 +25,8 @@ use phpOMS\DataStorage\LockException;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
class HttpSession implements SessionInterface
{
@ -97,10 +99,10 @@ class HttpSession implements SessionInterface
$this->destroy();
}
$this->sessionData = $_SESSION;
$_SESSION = null;
$this->sessionData = $_SESSION;
$_SESSION = null;
$this->sessionData['lastActivity'] = time();
$this->sid = session_id();
$this->sid = session_id();
$this->setCsrfProtection();
}
@ -114,12 +116,12 @@ class HttpSession implements SessionInterface
{
$this->set('UID', 0, false);
if (($CSRF = $this->get('CSRF')) === null) {
$CSRF = StringUtils::generateString(10, 16);
$this->set('CSRF', $CSRF, false);
if (($csrf = $this->get('CSRF')) === null) {
$csrf = StringUtils::generateString(10, 16);
$this->set('CSRF', $csrf, false);
}
UriFactory::setQuery('$CSRF', $CSRF);
UriFactory::setQuery('$CSRF', $csrf);
}
/**

View File

@ -174,7 +174,7 @@ class Dispatcher
if (!isset($this->controllers[$controller])) {
// If module controller use module manager for initialization
if (strpos('\Modules\Controller', $controller) === 0) {
$split = explode('\\', $controller);
$split = explode('\\', $controller);
$this->controllers[$controller] = $this->app->moduleManager->get($split[2]);
} else {
$this->controllers[$controller] = new $controller($this->app);

View File

@ -275,4 +275,4 @@ class ISO3166CharEnum extends Enum
/* public */ const _YEM = 'YEM';
/* public */ const _ZMB = 'ZMB';
/* public */ const _ZWE = 'ZWE';
}
}

View File

@ -276,4 +276,4 @@ class ISO3166NameEnum extends Enum
/* public */ const _ZMB = 'Zambia';
/* public */ const _ZWE = 'Zimbabwe';
/* public */ const _XKK = 'Kosovo';
}
}

View File

@ -275,4 +275,4 @@ class ISO3166NumEnum extends Enum
/* public */ const _YEM = '887';
/* public */ const _ZMB = '894';
/* public */ const _ZWE = '716';
}
}

View File

@ -276,4 +276,4 @@ class ISO3166TwoEnum extends Enum
/* public */ const _ZMB = 'ZM';
/* public */ const _ZWE = 'ZW';
/* public */ const _XKK = 'XK';
}
}

View File

@ -204,4 +204,4 @@ class ISO4217DecimalEnum extends Enum
/* public */ const _YER = 2;
/* public */ const _ZAR = 2;
/* public */ const _ZMW = 2;
}
}

View File

@ -204,4 +204,4 @@ class ISO4217NumEnum extends Enum
/* public */ const _YER = '886';
/* public */ const _ZAR = '710';
/* public */ const _ZMW = '967';
}
}

View File

@ -180,4 +180,4 @@ class ISO4217SubUnitEnum extends Enum
/* public */ const _ZAR = 100;
/* public */ const _ZMK = 100;
/* public */ const _ZWL = 100;
}
}

View File

@ -135,4 +135,4 @@ class ISO4217SymbolEnum extends Enum
/* public */ const _VND = '₫';
/* public */ const _YER = '﷼';
/* public */ const _ZWD = 'Z$';
}
}

View File

@ -404,7 +404,7 @@ class Localization
*/
public function setWeight(array $weight) /* : void */
{
$this->weight= $weight;
$this->weight = $weight;
}
/**

View File

@ -24,12 +24,14 @@ use phpOMS\System\File\Local\File;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
class FileLogger implements LoggerInterface
{
/* public */ const MSG_BACKTRACE = '{datetime}; {level}; {ip}; {message}; {backtrace}';
/* public */ const MSG_FULL = '{datetime}; {level}; {ip}; {line}; {version}; {os}; {path}; {message}; {file}; {backtrace}';
/* public */ const MSG_SIMPLE = '{datetime}; {level}; {ip}; {message};';
/* public */ const MSG_FULL = '{datetime}; {level}; {ip}; {line}; {version}; {os}; {path}; {message}; {file}; {backtrace}';
/* public */ const MSG_SIMPLE = '{datetime}; {level}; {ip}; {message};';
/**
* Timing array.

View File

@ -27,11 +27,11 @@ use phpOMS\Stdlib\Base\Enum;
abstract class LogLevel extends Enum
{
/* public */ const EMERGENCY = 'emergency';
/* public */ const ALERT = 'alert';
/* public */ const CRITICAL = 'critical';
/* public */ const ERROR = 'error';
/* public */ const WARNING = 'warning';
/* public */ const NOTICE = 'notice';
/* public */ const INFO = 'info';
/* public */ const DEBUG = 'debug';
/* public */ const ALERT = 'alert';
/* public */ const CRITICAL = 'critical';
/* public */ const ERROR = 'error';
/* public */ const WARNING = 'warning';
/* public */ const NOTICE = 'notice';
/* public */ const INFO = 'info';
/* public */ const DEBUG = 'debug';
}

View File

@ -57,14 +57,14 @@ class Fibunacci
return $start;
}
$old_1 = $start;
$old_2 = $start;
$fib = 0;
$old1 = $start;
$old2 = $start;
$fib = 0;
for ($i = 2; $i < $n; $i++) {
$fib = $old_1 + $old_2;
$old_1 = $old_2;
$old_2 = $fib;
$fib = $old1 + $old2;
$old1 = $old2;
$old2 = $fib;
}
return $fib;

View File

@ -40,7 +40,7 @@ final class MonotoneChain
if (($n = count($points)) > 1) {
uasort($points, [self::class, 'sort']);
$k = 0;
$k = 0;
$result = [];
// Lower hull
@ -99,4 +99,4 @@ final class MonotoneChain
{
return $a['x'] === $b['x'] ? $a['y'] - $b['y'] : $a['x'] - $b['x'];
}
}
}

View File

@ -75,6 +75,9 @@ class Circle implements D2ShapeInterface
* @return float
*
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
*/
public static function getRadiusByPerimeter(float $C) : float
{

View File

@ -99,10 +99,10 @@ class Polygon implements D2ShapeInterface
// Inside or ontop?
$countIntersect = 0;
$polygon_count = count($polygon);
$polygonCount = count($polygon);
// todo: return based on highest possibility not by first match
for ($i = 1; $i < $polygon_count; $i++) {
for ($i = 1; $i < $polygonCount; $i++) {
$vertex1 = $polygon[$i - 1];
$vertex2 = $polygon[$i];

View File

@ -16,4 +16,4 @@ namespace phpOMS\Math\Geometry\Shape\D2;
class Quadrilateral implements D2ShapeInterface
{
}
}

View File

@ -79,6 +79,9 @@ class Cone implements D3ShapeInterface
* @return float
*
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
*/
public static function getHeightFromVolume(float $V, float $r) : float
{

View File

@ -141,6 +141,9 @@ class Sphere implements D3ShapeInterface
* @return float
*
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
*/
public static function getRadiusBySurface(float $S) : float
{

View File

@ -26,13 +26,13 @@ use phpOMS\Stdlib\Base\Enum;
*/
abstract class NumberType extends Enum
{
/* public */ const N_INTEGER = 0;
/* public */ const N_NATURAL = 1;
/* public */ const N_EVEN = 2;
/* public */ const N_UNEVEN = 4;
/* public */ const N_PRIME = 8;
/* public */ const N_REAL = 16;
/* public */ const N_RATIONAL = 32;
/* public */ const N_INTEGER = 0;
/* public */ const N_NATURAL = 1;
/* public */ const N_EVEN = 2;
/* public */ const N_UNEVEN = 4;
/* public */ const N_PRIME = 8;
/* public */ const N_REAL = 16;
/* public */ const N_RATIONAL = 32;
/* public */ const N_IRRATIONAL = 64;
/* public */ const N_COMPLEX = 128;
/* public */ const N_COMPLEX = 128;
}

View File

@ -43,7 +43,7 @@ class Numbers
}
}
return $sum == $n;
return $sum === $n;
}
/**
@ -57,7 +57,7 @@ class Numbers
*/
public static function isSelfdescribing(int $n) : bool
{
$n = (string) $n;
$n = (string) $n;
$split = str_split($n);
foreach ($split as $place => $value) {
@ -106,4 +106,4 @@ class Numbers
return $count;
}
}
}

View File

@ -87,4 +87,4 @@ interface OperationInterface
* @since 1.0.0
*/
public function abs();
}
}

View File

@ -167,4 +167,4 @@ class Prime
return true;
}
}
}

View File

@ -25,4 +25,4 @@ namespace phpOMS\Math\Optimization\Graph;
class NullEdge
{
}
}

View File

@ -25,4 +25,4 @@ namespace phpOMS\Math\Optimization\Graph;
class NullVertice
{
}
}

View File

@ -28,17 +28,17 @@ use phpOMS\Math\Matrix\Exception\InvalidDimensionException;
class Average
{
/* public */ const MA3 = [1 / 3, 1 / 3];
/* public */ const MA5 = [0.2, 0.2, 0.2];
/* public */ const MA3 = [1 / 3, 1 / 3];
/* public */ const MA5 = [0.2, 0.2, 0.2];
/* public */ const MA2x12 = [5 / 6, 5 / 6, 5 / 6, 5 / 6, 5 / 6, 5 / 6, 0.42];
/* public */ const MA3x3 = [1 / 3, 2 / 9, 1 / 9];
/* public */ const MA3x5 = [0.2, 0.2, 2 / 15, 4 / 6];
/* public */ const MAS15 = [0.231, 0.209, 0.144, 2 / 3, 0.009, -0.016, -0.019, -0.009];
/* public */ const MAS21 = [0.171, 0.163, 0.134, 0.37, 0.51, 0.017, -0.006, -0.014, -0.014, -0.009, -0.003];
/* public */ const MAH5 = [0.558, 0.294, -0.73];
/* public */ const MAH9 = [0.330, 0.267, 0.119, -0.010, -0.041];
/* public */ const MAH13 = [0.240, 0.214, 0.147, 0.66, 0, -0.028, -0.019];
/* public */ const MAH23 = [0.148, 0.138, 0.122, 0.097, 0.068, 0.039, 0.013, -0.005, -0.015, -0.016, -0.011, -0.004];
/* public */ const MA3x3 = [1 / 3, 2 / 9, 1 / 9];
/* public */ const MA3x5 = [0.2, 0.2, 2 / 15, 4 / 6];
/* public */ const MAS15 = [0.231, 0.209, 0.144, 2 / 3, 0.009, -0.016, -0.019, -0.009];
/* public */ const MAS21 = [0.171, 0.163, 0.134, 0.37, 0.51, 0.017, -0.006, -0.014, -0.014, -0.009, -0.003];
/* public */ const MAH5 = [0.558, 0.294, -0.73];
/* public */ const MAH9 = [0.330, 0.267, 0.119, -0.010, -0.041];
/* public */ const MAH13 = [0.240, 0.214, 0.147, 0.66, 0, -0.028, -0.019];
/* public */ const MAH23 = [0.148, 0.138, 0.122, 0.097, 0.068, 0.039, 0.013, -0.005, -0.015, -0.016, -0.011, -0.004];
/**
* Average change.

View File

@ -39,7 +39,7 @@ class Basic
public static function freaquency(array $values) : array
{
$freaquency = [];
$sum = 1;
$sum = 1;
if (!($isArray = is_array(reset($values)))) {
$sum = array_sum($values);

View File

@ -99,7 +99,7 @@ class ChiSquaredDistribution
$sum += ($dataset[$i] - $expected[$i]) * ($dataset[$i] - $expected[$i]) / $expected[$i];
}
$P = null;
$p = null;
if ($df === 0) {
$df = self::getDegreesOfFreedom($dataset);
@ -111,14 +111,14 @@ class ChiSquaredDistribution
foreach (self::TABLE[$df] as $key => $value) {
if ($value > $sum) {
$P = $key;
$p = $key;
break;
}
}
$P = 1 - ($P ?? key(end(self::TABLE[$df])));
$p = 1 - ($p ?? key(end(self::TABLE[$df])));
return ['P' => $P, 'H0' => ($P > $significance), 'df' => $df];
return ['P' => $p, 'H0' => ($p > $significance), 'df' => $df];
}
/**

View File

@ -24,6 +24,8 @@ use phpOMS\DataStorage\LockException;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
class Header extends HeaderAbstract
{

View File

@ -29,6 +29,8 @@ use phpOMS\Uri\UriInterface;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
class Request extends RequestAbstract
{

View File

@ -100,24 +100,24 @@ class SmartDateTime extends \DateTime
*/
public function smartModify(int $y, int $m = 0, int $d = 0, int $calendar = CAL_GREGORIAN) : SmartDateTime
{
$y_change = (int) floor(((int) $this->format('m') - 1 + $m) / 12);
$y_change = ((int) $this->format('m') - 1 + $m) < 0 && ((int) $this->format('m') - 1 + $m) % 12 === 0 ? $y_change - 1 : $y_change;
$y_new = (int) $this->format('Y') + $y + $y_change;
$m_new = ((int) $this->format('m') + $m) % 12;
$m_new = $m_new === 0 ? 12 : $m_new < 0 ? 12 + $m_new : $m_new;
$d_month_old = cal_days_in_month($calendar, (int) $this->format('m'), (int) $this->format('Y'));
$d_month_new = cal_days_in_month($calendar, $m_new, $y_new);
$d_old = (int) $this->format('d');
$yearChange = (int) floor(((int) $this->format('m') - 1 + $m) / 12);
$yearChange = ((int) $this->format('m') - 1 + $m) < 0 && ((int) $this->format('m') - 1 + $m) % 12 === 0 ? $yearChange - 1 : $yearChange;
$yearNew = (int) $this->format('Y') + $y + $yearChange;
$monthNew = ((int) $this->format('m') + $m) % 12;
$monthNew = $monthNew === 0 ? 12 : $monthNew < 0 ? 12 + $monthNew : $monthNew;
$dayMonthOld = cal_days_in_month($calendar, (int) $this->format('m'), (int) $this->format('Y'));
$dayMonthNew = cal_days_in_month($calendar, $monthNew, $yearNew);
$dayOld = (int) $this->format('d');
if ($d_old > $d_month_new) {
$d_new = $d_month_new;
} elseif ($d_old < $d_month_new && $d_old === $d_month_old) {
$d_new = $d_month_new;
if ($dayOld > $dayMonthNew) {
$dayNew = $dayMonthNew;
} elseif ($dayOld < $dayMonthNew && $dayOld === $dayMonthOld) {
$dayNew = $dayMonthNew;
} else {
$d_new = $d_old;
$dayNew = $dayOld;
}
$this->setDate($y_new, $m_new, $d_new);
$this->setDate($yearNew, $monthNew, $dayNew);
if ($d !== 0) {
$this->modify($d . ' day');

View File

@ -91,8 +91,7 @@ class File extends FileAbstract implements FileInterface
$exists = self::ftpExists($con, $http->getPath());
if (
(ContentPutMode::hasFlag($mode, ContentPutMode::APPEND) && $exists)
if ((ContentPutMode::hasFlag($mode, ContentPutMode::APPEND) && $exists)
|| (ContentPutMode::hasFlag($mode, ContentPutMode::PREPEND) && $exists)
|| (ContentPutMode::hasFlag($mode, ContentPutMode::REPLACE) && $exists)
|| (!$exists && ContentPutMode::hasFlag($mode, ContentPutMode::CREATE))
@ -124,10 +123,10 @@ class File extends FileAbstract implements FileInterface
*/
public static function get(string $path) : string
{
$temp = fopen('php://temp', 'r+');
$http = new Http($path);
$temp = fopen('php://temp', 'r+');
$http = new Http($path);
$content = '';
$con = self::ftpConnect($http);
$con = self::ftpConnect($http);
if (ftp_chdir($con, File::dirpath($path)) && ftp_fget($con, $temp, $path, FTP_BINARY, 0)) {
rewind($temp);
@ -168,8 +167,8 @@ class File extends FileAbstract implements FileInterface
*/
public static function exists(string $path) : bool
{
$http = new Http($path);
$con = self::ftpConnect($http);
$http = new Http($path);
$con = self::ftpConnect($http);
$exists = self::ftpExists($con, $http->getPath());
fclose($con);
@ -206,8 +205,8 @@ class File extends FileAbstract implements FileInterface
*/
public static function changed(string $path) : \DateTime
{
$http = new Http($path);
$con = self::ftpConnect($http);
$http = new Http($path);
$con = self::ftpConnect($http);
$changed = new \DateTime();
$changed->setTimestamp(ftp_mdtm($con, $http->getPath()));
@ -223,7 +222,7 @@ class File extends FileAbstract implements FileInterface
public static function size(string $path, bool $recursive = true) : int
{
$http = new Http($path);
$con = self::ftpConnect($http);
$con = self::ftpConnect($http);
if (!self::exists($http->getPath())) {
throw new PathException($path);
@ -241,8 +240,8 @@ class File extends FileAbstract implements FileInterface
*/
public static function owner(string $path) : int
{
$http = new Http($path);
$con = self::ftpConnect($http);
$http = new Http($path);
$con = self::ftpConnect($http);
$owner = self::parseFtpFileData($con, $path)['user'] ?? '';
fclose($con);
@ -255,8 +254,8 @@ class File extends FileAbstract implements FileInterface
*/
public static function permission(string $path) : int
{
$http = new Http($path);
$con = self::ftpConnect($http);
$http = new Http($path);
$con = self::ftpConnect($http);
$permission = (int) self::parseFtpFileData($con, $path)['permission'] ?? 0;
fclose($con);
@ -274,10 +273,10 @@ class File extends FileAbstract implements FileInterface
$chunks = preg_split("/\s+/", $fileData);
$items['permission'] = $chunks[0];
$items['user'] = $chunks[2];
$items['group'] = $chunks[3];
$items['size'] = $chunks[4];
$items['type'] = $chunks[0][0] === 'd' ? 'directory' : 'file';
$items['user'] = $chunks[2];
$items['group'] = $chunks[3];
$items['size'] = $chunks[4];
$items['type'] = $chunks[0][0] === 'd' ? 'directory' : 'file';
break;
}
@ -336,7 +335,7 @@ class File extends FileAbstract implements FileInterface
{
// todo: handle different ftp connections AND local to ftp
$http = new Http($to);
$con = self::ftpConnect($http);
$con = self::ftpConnect($http);
if (!self::ftpExists($con, $from)) {
throw new PathException($from);
@ -364,7 +363,7 @@ class File extends FileAbstract implements FileInterface
public static function delete(string $path) : bool
{
$http = new Http($path);
$con = self::ftpConnect($http);
$con = self::ftpConnect($http);
if (!self::ftpExists($con, $path)) {
return false;

View File

@ -13,6 +13,7 @@
declare(strict_types = 1);
namespace phpOMS\System\File\Ftp;
use phpOMS\System\File\StorageAbstract;
use phpOMS\System\File\PathException;

View File

@ -142,8 +142,8 @@ class Directory extends FileAbstract implements DirectoryInterface
*/
public function addNode($file) : bool
{
$this->count += $file->getCount();
$this->size += $file->getSize();
$this->count += $file->getCount();
$this->size += $file->getSize();
$this->nodes[$file->getName()] = $file;
return $file->createNode();
@ -158,10 +158,10 @@ class Directory extends FileAbstract implements DirectoryInterface
throw new PathException($dir);
}
$countSize = 0;
$dir_array = scandir($dir);
$countSize = 0;
$directories = scandir($dir);
foreach ($dir_array as $key => $filename) {
foreach ($directories as $key => $filename) {
if ($filename === ".." || $filename === ".") {
continue;
}
@ -186,8 +186,8 @@ class Directory extends FileAbstract implements DirectoryInterface
throw new PathException($path);
}
$size = 0;
$files = scandir($path);
$size = 0;
$files = scandir($path);
$ignore[] = '.';
$ignore[] = '..';
@ -411,7 +411,7 @@ class Directory extends FileAbstract implements DirectoryInterface
{
if (isset($this->nodes[$name])) {
$this->count -= $this->nodes[$name]->getCount();
$this->size -= $this->nodes[$name]->getSize();
$this->size -= $this->nodes[$name]->getSize();
unset($this->nodes[$name]);
@ -568,4 +568,4 @@ class Directory extends FileAbstract implements DirectoryInterface
{
// TODO: Implement offsetGet() method.
}
}
}

View File

@ -66,8 +66,7 @@ class File extends FileAbstract implements FileInterface
{
$exists = file_exists($path);
if (
(ContentPutMode::hasFlag($mode, ContentPutMode::APPEND) && $exists)
if ((ContentPutMode::hasFlag($mode, ContentPutMode::APPEND) && $exists)
|| (ContentPutMode::hasFlag($mode, ContentPutMode::PREPEND) && $exists)
|| (ContentPutMode::hasFlag($mode, ContentPutMode::REPLACE) && $exists)
|| (!$exists && ContentPutMode::hasFlag($mode, ContentPutMode::CREATE))
@ -486,4 +485,4 @@ class File extends FileAbstract implements FileInterface
return $extension[1] ?? '';
}
}
}

View File

@ -13,6 +13,7 @@
declare(strict_types = 1);
namespace phpOMS\System\File\Local;
use phpOMS\System\File\ContainerInterface;
/**
@ -189,4 +190,4 @@ abstract class FileAbstract implements ContainerInterface
$this->owner = fileowner($this->path);
$this->permission = (int) substr(sprintf('%o', fileperms($this->path)), -4);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -79,19 +79,19 @@ class SystemUtils
*/
public static function getRAMUsage() : int
{
$memusage = 0;
$memUsage = 0;
if (stristr(PHP_OS, 'LINUX')) {
$free = shell_exec('free');
$free = (string) trim($free);
$free_arr = explode("\n", $free);
$mem = explode(" ", $free_arr[1]);
$freeArr = explode("\n", $free);
$mem = explode(" ", $freeArr[1]);
$mem = array_filter($mem);
$mem = array_merge($mem);
$memusage = $mem[2] / $mem[1] * 100;
$memUsage = $mem[2] / $mem[1] * 100;
}
return (int) $memusage;
return (int) $memUsage;
}
/**
@ -103,16 +103,16 @@ class SystemUtils
*/
public static function getCpuUsage() : int
{
$cpuusage = 0;
$cpuUsage = 0;
if (stristr(PHP_OS, 'WIN') !== false) {
$cpuusage = null;
exec('wmic cpu get LoadPercentage', $cpuusage);
$cpuusage = $cpuusage[1];
$cpuUsage = null;
exec('wmic cpu get LoadPercentage', $cpuUsage);
$cpuUsage = $cpuUsage[1];
} elseif (stristr(PHP_OS, 'LINUX') !== false) {
$cpuusage = \sys_getloadavg()[0] * 100;
$cpuUsage = \sys_getloadavg()[0] * 100;
}
return (int) $cpuusage;
return (int) $cpuUsage;
}
}

View File

@ -25,6 +25,8 @@ use phpOMS\Utils\StringUtils;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
class Http implements UriInterface
{

View File

@ -23,6 +23,9 @@ use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
abstract class C128Abstract
{

View File

@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
class C128a extends C128Abstract
{

View File

@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
class C128b extends C128Abstract
{

View File

@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
class C128c extends C128Abstract
{

View File

@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
class C25 extends C128Abstract
{

View File

@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
class C39 extends C128Abstract
{

View File

@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
class Codebar extends C128Abstract
{

View File

@ -134,8 +134,8 @@ class Text
$words = self::$wordsWest;
}
$punctuation = $this->generatePunctuation($length);
$punctuation_count = array_count_values(
$punctuation = $this->generatePunctuation($length);
$punctuationCount = array_count_values(
array_map(
function ($item) {
return $item[1];
@ -144,7 +144,7 @@ class Text
)
) + ['.' => 0, '!' => 0, '?' => 0];
$this->sentences = $punctuation_count['.'] + $punctuation_count['!'] + $punctuation_count['?'];
$this->sentences = $punctuationCount['.'] + $punctuationCount['!'] + $punctuationCount['?'];
if ($this->hasParagraphs) {
$paragraph = $this->generateParagraph($this->sentences);
@ -233,16 +233,16 @@ class Text
}
/* Handle comma */
$comma_here = (rand(0, 100) <= $probComma * 100 && $sentenceLength >= 2 * $minCommaSpacing ? true : false);
$posComma = [];
$commaHere = (rand(0, 100) <= $probComma * 100 && $sentenceLength >= 2 * $minCommaSpacing ? true : false);
$posComma = [];
if ($comma_here) {
if ($commaHere) {
$posComma[] = rand($minCommaSpacing, $sentenceLength - $minCommaSpacing);
$punctuation[] = [$i + $posComma[0], ','];
$comma_here = (rand(0, 100) <= $probComma * 100 && $posComma[0] + $minCommaSpacing * 2 < $sentenceLength ? true : false);
$commaHere = (rand(0, 100) <= $probComma * 100 && $posComma[0] + $minCommaSpacing * 2 < $sentenceLength ? true : false);
if ($comma_here) {
if ($commaHere) {
$posComma[] = rand($posComma[0] + $minCommaSpacing, $sentenceLength - $minCommaSpacing);
$punctuation[] = [$i + $posComma[1], ','];
}
@ -251,16 +251,16 @@ class Text
$i += $sentenceLength;
/* Handle sentence ending */
$is_dot = (rand(0, 100) <= $probDot * 100 ? true : false);
$isDot = (rand(0, 100) <= $probDot * 100 ? true : false);
if ($is_dot) {
if ($isDot) {
$punctuation[] = [$i, '.'];
continue;
}
$is_ex = (rand(0, 100) <= $probExc * 100 ? true : false);
$isEx = (rand(0, 100) <= $probExc * 100 ? true : false);
if ($is_ex) {
if ($isEx) {
$punctuation[] = [$i, '!'];
continue;
}

View File

@ -23,6 +23,8 @@ namespace phpOMS\Utils;
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
*/
class StringUtils
{

View File

@ -44,12 +44,12 @@ abstract class CreditCard extends ValidatorAbstract
$value = preg_replace('/\D/', '', $value);
// Set the string length and parity
$number_length = strlen($value);
$parity = $number_length % 2;
$numberLength = strlen($value);
$parity = $numberLength % 2;
// Loop through each digit and do the maths
$total = 0;
for ($i = 0; $i < $number_length; $i++) {
for ($i = 0; $i < $numberLength; $i++) {
$digit = $value[$i];
// Multiply alternate digits by two
if ($i % 2 == $parity) {

View File

@ -22,12 +22,12 @@ class GATest extends \PHPUnit\Framework\TestCase
{
public function testTsp()
{
$cities = [new City()];
$cities = [new City()];
$cityPool = new CityPool($cities);
$ga = new Ga($cityPool);
$ga = new Ga($cityPool);
$basePopulation = new Population($cityPool, 1000, true);
$population = $ga->evolvePopulation($basePopulation);
$population = $ga->evolvePopulation($basePopulation);
}
}

View File

@ -22,9 +22,9 @@ class StringUtilsTest extends \PHPUnit\Framework\TestCase
*/
public function testStrings()
{
$haystack = [];
$haystack = [];
$outOfBounds = false;
$randomness = 0;
$randomness = 0;
for ($i = 0; $i < 10000; $i++) {
$random = StringUtils::generateString(5, 12, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_?><|;"');