mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 05:58:42 +00:00
More codestyle fixes
This commit is contained in:
parent
51cd98b1a7
commit
f1288ebc03
|
|
@ -166,10 +166,10 @@ class Account implements ArrayableInterface, \JsonSerializable
|
||||||
*/
|
*/
|
||||||
public function __construct(int $id = 0)
|
public function __construct(int $id = 0)
|
||||||
{
|
{
|
||||||
$this->createdAt = new \DateTime('now');
|
$this->createdAt = new \DateTime('now');
|
||||||
$this->lastActive = new \DateTime('now');
|
$this->lastActive = new \DateTime('now');
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->l11n = new NullLocalization();
|
$this->l11n = new NullLocalization();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -329,7 +329,8 @@ class Account implements ArrayableInterface, \JsonSerializable
|
||||||
&& ($p->getType() === $type || $p->getType() === null || !isset($type))
|
&& ($p->getType() === $type || $p->getType() === null || !isset($type))
|
||||||
&& ($p->getElement() === $element || $p->getElement() === null || !isset($element))
|
&& ($p->getElement() === $element || $p->getElement() === null || !isset($element))
|
||||||
&& ($p->getComponent() === $component || $p->getComponent() === null || !isset($component))
|
&& ($p->getComponent() === $component || $p->getComponent() === null || !isset($component))
|
||||||
&& ($p->getPermission() | $permission) === $p->getPermission()) {
|
&& ($p->getPermission() | $permission) === $p->getPermission()
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ use phpOMS\Math\Matrix\Exception\InvalidDimensionException;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
*/
|
*/
|
||||||
class FinanceFormulas
|
class FinanceFormulas
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,12 @@ use phpOMS\Math\Statistic\Average;
|
||||||
class ARIMA
|
class ARIMA
|
||||||
{
|
{
|
||||||
private $data = [];
|
private $data = [];
|
||||||
|
|
||||||
private $order = 0;
|
private $order = 0;
|
||||||
|
|
||||||
public function __construct(array $data, int $order = 12)
|
public function __construct(array $data, int $order = 12)
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
$this->order = $order;
|
$this->order = $order;
|
||||||
|
|
||||||
if ($order !== 12 && $order !== 4) {
|
if ($order !== 12 && $order !== 4) {
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -26,8 +26,8 @@ use phpOMS\Stdlib\Base\Enum;
|
||||||
*/
|
*/
|
||||||
abstract class SeasonalType extends Enum
|
abstract class SeasonalType extends Enum
|
||||||
{
|
{
|
||||||
/* public */ const ALL = 0;
|
/* public */ const ALL = 0;
|
||||||
/* public */ const NONE = 1;
|
/* public */ const NONE = 1;
|
||||||
/* public */ const ADDITIVE = 2;
|
/* public */ const ADDITIVE = 2;
|
||||||
/* public */ const MULTIPLICATIVE = 4;
|
/* public */ const MULTIPLICATIVE = 4;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ use phpOMS\Stdlib\Base\Enum;
|
||||||
*/
|
*/
|
||||||
abstract class TrendType extends Enum
|
abstract class TrendType extends Enum
|
||||||
{
|
{
|
||||||
/* public */ const ALL = 0;
|
/* public */ const ALL = 0;
|
||||||
/* public */ const NONE = 1;
|
/* public */ const NONE = 1;
|
||||||
/* public */ const ADDITIVE = 2;
|
/* public */ const ADDITIVE = 2;
|
||||||
/* public */ const MULTIPLICATIVE = 4;
|
/* public */ const MULTIPLICATIVE = 4;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,3 @@ class MA
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,3 @@ class NAR
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,3 @@ class NMA
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,3 @@ class SARIMA
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ namespace phpOMS\Business\Finance;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
*/
|
*/
|
||||||
class Loan
|
class Loan
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ namespace phpOMS\Business\Finance;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
*/
|
*/
|
||||||
class StockBonds
|
class StockBonds
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ namespace phpOMS\Business\Marketing;
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class Metrics {
|
class Metrics
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Calculate customer retention
|
* Calculate customer retention
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ namespace phpOMS\Business\Marketing;
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class NetPromoterScore {
|
class NetPromoterScore
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Score values
|
* Score values
|
||||||
*
|
*
|
||||||
|
|
@ -39,7 +40,8 @@ class NetPromoterScore {
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ namespace phpOMS\Business\Programming;
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class Metrics {
|
class Metrics
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Calculate ABC metric score
|
* Calculate ABC metric score
|
||||||
*
|
*
|
||||||
|
|
@ -54,6 +55,8 @@ class Metrics {
|
||||||
* @return int
|
* @return int
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
|
||||||
*/
|
*/
|
||||||
public static function CRAP(int $complexity, float $coverage) : int
|
public static function CRAP(int $complexity, float $coverage) : int
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ namespace phpOMS\Business\Sales;
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class MarketShareEstimation {
|
class MarketShareEstimation
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Calculate rank (r) based on market share (m)
|
* Calculate rank (r) based on market share (m)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -71,5 +71,4 @@ interface OptionsInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getOption($key);
|
public function getOption($key);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ abstract class SettingsAbstract implements OptionsInterface
|
||||||
if ($store) {
|
if ($store) {
|
||||||
foreach($this->options as $key => $option) {
|
foreach($this->options as $key => $option) {
|
||||||
$query = new Builder($this->connection);
|
$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])
|
->set([static::$columns[1] => $option])
|
||||||
->where(static::$columns[0], '=', $key)
|
->where(static::$columns[0], '=', $key)
|
||||||
->toSql();
|
->toSql();
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,4 @@ interface ArrayableInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function toArray() : array;
|
public function toArray() : array;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,5 +36,4 @@ interface RenderableInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function render() : string;
|
public function render() : string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace phpOMS\DataStorage\Cache;
|
namespace phpOMS\DataStorage\Cache;
|
||||||
|
|
||||||
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
|
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -139,5 +140,4 @@ interface CacheInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getThreshold() : int;
|
public function getThreshold() : int;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class CachePool implements OptionsInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @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])) {
|
if (isset($this->pool[$key])) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ use phpOMS\Stdlib\Base\Enum;
|
||||||
*/
|
*/
|
||||||
abstract class CacheStatus extends Enum
|
abstract class CacheStatus extends Enum
|
||||||
{
|
{
|
||||||
/* public */ const ACTIVE = 0;
|
/* public */ const ACTIVE = 0;
|
||||||
/* public */ const INACTIVE = 1;
|
/* public */ const INACTIVE = 1;
|
||||||
/* public */ const ERROR = 2;
|
/* public */ const ERROR = 2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,11 @@ use phpOMS\Stdlib\Base\Enum;
|
||||||
*/
|
*/
|
||||||
abstract class CacheType extends Enum
|
abstract class CacheType extends Enum
|
||||||
{
|
{
|
||||||
/* public */ const _INT = 0; /* Data is integer */
|
/* public */ const _INT = 0; /* Data is integer */
|
||||||
/* public */ const _STRING = 1; /* Data is string */
|
/* public */ const _STRING = 1; /* Data is string */
|
||||||
/* public */ const _ARRAY = 2; /* Data is array */
|
/* public */ const _ARRAY = 2; /* Data is array */
|
||||||
/* public */ const _SERIALIZABLE = 3; /* Data is object */
|
/* public */ const _SERIALIZABLE = 3; /* Data is object */
|
||||||
/* public */ const _FLOAT = 4; /* Data is float */
|
/* public */ const _FLOAT = 4; /* Data is float */
|
||||||
/* public */ const _BOOL = 5; /* Data is bool */
|
/* public */ const _BOOL = 5; /* Data is bool */
|
||||||
/* public */ const _JSONSERIALIZABLE = 6;
|
/* public */ const _JSONSERIALIZABLE = 6;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -383,8 +383,7 @@ class FileCache implements CacheInterface
|
||||||
foreach ($dir as $file) {
|
foreach ($dir as $file) {
|
||||||
if ($file instanceof File) {
|
if ($file instanceof File) {
|
||||||
$created = $file->getCreatedAt()->getTimestamp();
|
$created = $file->getCreatedAt()->getTimestamp();
|
||||||
if (
|
if (($expire >= 0 && $created + $expire < $now)
|
||||||
($expire >= 0 && $created + $expire < $now)
|
|
||||||
|| ($expire < 0 && $created + $this->getExpire($file->getContent()) < $now)
|
|| ($expire < 0 && $created + $this->getExpire($file->getContent()) < $now)
|
||||||
) {
|
) {
|
||||||
File::delete($file->getPath());
|
File::delete($file->getPath());
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ class CookieJar
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.Superglobals)
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -127,5 +127,4 @@ interface DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function get($primaryKey);
|
public static function get($primaryKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,8 @@ class ConnectionFactory
|
||||||
switch ($dbdata['db']) {
|
switch ($dbdata['db']) {
|
||||||
case DatabaseType::MYSQL:
|
case DatabaseType::MYSQL:
|
||||||
return new MysqlConnection($dbdata);
|
return new MysqlConnection($dbdata);
|
||||||
break;
|
|
||||||
case DatabaseType::SQLSRV:
|
case DatabaseType::SQLSRV:
|
||||||
return new SqlServerConnection($dbdata);
|
return new SqlServerConnection($dbdata);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException('Database "' . $dbdata['db'] . '" is not supported.');
|
throw new \InvalidArgumentException('Database "' . $dbdata['db'] . '" is not supported.');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static $language_field = '';
|
protected static $languageField = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Columns.
|
* Columns.
|
||||||
|
|
@ -2129,8 +2129,8 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
$query->orderBy(static::$table . '.' . static::$columns[static::$primaryField]['name'], 'DESC');
|
$query->orderBy(static::$table . '.' . static::$columns[static::$primaryField]['name'], 'DESC');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty(self::$language_field) && !empty($lang)) {
|
if (!empty(self::$languageField) && !empty($lang)) {
|
||||||
$query->where(static::$table . '.' . static::$language_field, '=', $lang, 'AND');
|
$query->where(static::$table . '.' . static::$languageField, '=', $lang, 'AND');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sth = self::$db->con->prepare($query->toSql());
|
$sth = self::$db->con->prepare($query->toSql());
|
||||||
|
|
@ -2392,8 +2392,8 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
{
|
{
|
||||||
$query = self::getQuery();
|
$query = self::getQuery();
|
||||||
|
|
||||||
if (!empty(self::$language_field) && !empty($lang)) {
|
if (!empty(self::$languageField) && !empty($lang)) {
|
||||||
$query->where(static::$table . '.' . static::$language_field, '=', $lang, 'AND');
|
$query->where(static::$table . '.' . static::$languageField, '=', $lang, 'AND');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sth = self::$db->con->prepare($query->toSql());
|
$sth = self::$db->con->prepare($query->toSql());
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class DatabasePool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @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])) {
|
if (isset($this->pool[$key])) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ use phpOMS\Stdlib\Base\Enum;
|
||||||
*/
|
*/
|
||||||
abstract class DatabaseType extends Enum
|
abstract class DatabaseType extends Enum
|
||||||
{
|
{
|
||||||
/* public */ const MYSQL = 'mysql'; /* MySQL */
|
/* public */ const MYSQL = 'mysql'; /* MySQL */
|
||||||
/* public */ const SQLITE = 'sqlite'; /* SQLITE */
|
/* public */ const SQLITE = 'sqlite'; /* SQLITE */
|
||||||
/* public */ const PGSQL = 2; /* PostgreSQL */
|
/* public */ const PGSQL = 2; /* PostgreSQL */
|
||||||
/* public */ const ORACLE = 3; /* Oracle */
|
/* public */ const ORACLE = 3; /* Oracle */
|
||||||
/* public */ const SQLSRV = 'mssql'; /* Microsoft SQL Server */
|
/* public */ const SQLSRV = 'mssql'; /* Microsoft SQL Server */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\Query\Builder;
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\Query\Builder;
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\Query\Builder;
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\Query\Builder;
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
namespace phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\Query\Builder;
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,15 +26,15 @@ use phpOMS\Stdlib\Base\Enum;
|
||||||
*/
|
*/
|
||||||
abstract class JoinType extends Enum
|
abstract class JoinType extends Enum
|
||||||
{
|
{
|
||||||
/* public */ const JOIN = 'JOIN';
|
/* public */ const JOIN = 'JOIN';
|
||||||
/* public */ const LEFT_JOIN = 'LEFT JOIN';
|
/* public */ const LEFT_JOIN = 'LEFT JOIN';
|
||||||
/* public */ const LEFT_OUTER_JOIN = 'LEFT OUTER JOIN';
|
/* public */ const LEFT_OUTER_JOIN = 'LEFT OUTER JOIN';
|
||||||
/* public */ const LEFT_INNER_JOIN = 'LEFT INNER JOIN';
|
/* public */ const LEFT_INNER_JOIN = 'LEFT INNER JOIN';
|
||||||
/* public */ const RIGHT_JOIN = 'RIGHT JOIN';
|
/* public */ const RIGHT_JOIN = 'RIGHT JOIN';
|
||||||
/* public */ const RIGHT_OUTER_JOIN = 'RIGHT OUTER JOIN';
|
/* public */ const RIGHT_OUTER_JOIN = 'RIGHT OUTER JOIN';
|
||||||
/* public */ const RIGHT_INNER_JOIN = 'RIGHT INNER JOIN';
|
/* public */ const RIGHT_INNER_JOIN = 'RIGHT INNER JOIN';
|
||||||
/* public */ const OUTER_JOIN = 'OUTER JOIN';
|
/* public */ const OUTER_JOIN = 'OUTER JOIN';
|
||||||
/* public */ const INNER_JOIN = 'INNER JOIN';
|
/* public */ const INNER_JOIN = 'INNER JOIN';
|
||||||
/* public */ const CROSS_JOIN = 'CROSS JOIN';
|
/* public */ const CROSS_JOIN = 'CROSS JOIN';
|
||||||
/* public */ const FULL_OUTER_JOIN = 'FULL OUTER JOIN';
|
/* public */ const FULL_OUTER_JOIN = 'FULL OUTER JOIN';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,5 +31,5 @@ abstract class QueryType extends Enum
|
||||||
/* public */ const UPDATE = 2;
|
/* public */ const UPDATE = 2;
|
||||||
/* public */ const DELETE = 3;
|
/* public */ const DELETE = 3;
|
||||||
/* public */ const RANDOM = 4;
|
/* public */ const RANDOM = 4;
|
||||||
/* public */ const RAW = 5;
|
/* public */ const RAW = 5;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,16 +46,16 @@ class Builder extends BuilderAbstract
|
||||||
|
|
||||||
public function select(...$table) /* : void */
|
public function select(...$table) /* : void */
|
||||||
{
|
{
|
||||||
$this->type = QueryType::SELECT;
|
$this->type = QueryType::SELECT;
|
||||||
$this->table += $table;
|
$this->table += $table;
|
||||||
$this->table = array_unique($this->table);
|
$this->table = array_unique($this->table);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function drop(...$table)
|
public function drop(...$table)
|
||||||
{
|
{
|
||||||
$this->type = QueryType::DROP;
|
$this->type = QueryType::DROP;
|
||||||
$this->drop += $table;
|
$this->drop += $table;
|
||||||
$this->drop = array_unique($this->drop);
|
$this->drop = array_unique($this->drop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create(string $table)
|
public function create(string $table)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ use phpOMS\DataStorage\LockException;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.Superglobals)
|
||||||
*/
|
*/
|
||||||
class HttpSession implements SessionInterface
|
class HttpSession implements SessionInterface
|
||||||
{
|
{
|
||||||
|
|
@ -97,10 +99,10 @@ class HttpSession implements SessionInterface
|
||||||
$this->destroy();
|
$this->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->sessionData = $_SESSION;
|
$this->sessionData = $_SESSION;
|
||||||
$_SESSION = null;
|
$_SESSION = null;
|
||||||
$this->sessionData['lastActivity'] = time();
|
$this->sessionData['lastActivity'] = time();
|
||||||
$this->sid = session_id();
|
$this->sid = session_id();
|
||||||
|
|
||||||
$this->setCsrfProtection();
|
$this->setCsrfProtection();
|
||||||
}
|
}
|
||||||
|
|
@ -114,12 +116,12 @@ class HttpSession implements SessionInterface
|
||||||
{
|
{
|
||||||
$this->set('UID', 0, false);
|
$this->set('UID', 0, false);
|
||||||
|
|
||||||
if (($CSRF = $this->get('CSRF')) === null) {
|
if (($csrf = $this->get('CSRF')) === null) {
|
||||||
$CSRF = StringUtils::generateString(10, 16);
|
$csrf = StringUtils::generateString(10, 16);
|
||||||
$this->set('CSRF', $CSRF, false);
|
$this->set('CSRF', $csrf, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
UriFactory::setQuery('$CSRF', $CSRF);
|
UriFactory::setQuery('$CSRF', $csrf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ class Dispatcher
|
||||||
if (!isset($this->controllers[$controller])) {
|
if (!isset($this->controllers[$controller])) {
|
||||||
// If module controller use module manager for initialization
|
// If module controller use module manager for initialization
|
||||||
if (strpos('\Modules\Controller', $controller) === 0) {
|
if (strpos('\Modules\Controller', $controller) === 0) {
|
||||||
$split = explode('\\', $controller);
|
$split = explode('\\', $controller);
|
||||||
$this->controllers[$controller] = $this->app->moduleManager->get($split[2]);
|
$this->controllers[$controller] = $this->app->moduleManager->get($split[2]);
|
||||||
} else {
|
} else {
|
||||||
$this->controllers[$controller] = new $controller($this->app);
|
$this->controllers[$controller] = new $controller($this->app);
|
||||||
|
|
|
||||||
|
|
@ -404,7 +404,7 @@ class Localization
|
||||||
*/
|
*/
|
||||||
public function setWeight(array $weight) /* : void */
|
public function setWeight(array $weight) /* : void */
|
||||||
{
|
{
|
||||||
$this->weight= $weight;
|
$this->weight = $weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,14 @@ use phpOMS\System\File\Local\File;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.Superglobals)
|
||||||
*/
|
*/
|
||||||
class FileLogger implements LoggerInterface
|
class FileLogger implements LoggerInterface
|
||||||
{
|
{
|
||||||
/* public */ const MSG_BACKTRACE = '{datetime}; {level}; {ip}; {message}; {backtrace}';
|
/* 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_FULL = '{datetime}; {level}; {ip}; {line}; {version}; {os}; {path}; {message}; {file}; {backtrace}';
|
||||||
/* public */ const MSG_SIMPLE = '{datetime}; {level}; {ip}; {message};';
|
/* public */ const MSG_SIMPLE = '{datetime}; {level}; {ip}; {message};';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Timing array.
|
* Timing array.
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,11 @@ use phpOMS\Stdlib\Base\Enum;
|
||||||
abstract class LogLevel extends Enum
|
abstract class LogLevel extends Enum
|
||||||
{
|
{
|
||||||
/* public */ const EMERGENCY = 'emergency';
|
/* public */ const EMERGENCY = 'emergency';
|
||||||
/* public */ const ALERT = 'alert';
|
/* public */ const ALERT = 'alert';
|
||||||
/* public */ const CRITICAL = 'critical';
|
/* public */ const CRITICAL = 'critical';
|
||||||
/* public */ const ERROR = 'error';
|
/* public */ const ERROR = 'error';
|
||||||
/* public */ const WARNING = 'warning';
|
/* public */ const WARNING = 'warning';
|
||||||
/* public */ const NOTICE = 'notice';
|
/* public */ const NOTICE = 'notice';
|
||||||
/* public */ const INFO = 'info';
|
/* public */ const INFO = 'info';
|
||||||
/* public */ const DEBUG = 'debug';
|
/* public */ const DEBUG = 'debug';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,14 +57,14 @@ class Fibunacci
|
||||||
return $start;
|
return $start;
|
||||||
}
|
}
|
||||||
|
|
||||||
$old_1 = $start;
|
$old1 = $start;
|
||||||
$old_2 = $start;
|
$old2 = $start;
|
||||||
$fib = 0;
|
$fib = 0;
|
||||||
|
|
||||||
for ($i = 2; $i < $n; $i++) {
|
for ($i = 2; $i < $n; $i++) {
|
||||||
$fib = $old_1 + $old_2;
|
$fib = $old1 + $old2;
|
||||||
$old_1 = $old_2;
|
$old1 = $old2;
|
||||||
$old_2 = $fib;
|
$old2 = $fib;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fib;
|
return $fib;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ final class MonotoneChain
|
||||||
if (($n = count($points)) > 1) {
|
if (($n = count($points)) > 1) {
|
||||||
uasort($points, [self::class, 'sort']);
|
uasort($points, [self::class, 'sort']);
|
||||||
|
|
||||||
$k = 0;
|
$k = 0;
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
// Lower hull
|
// Lower hull
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,9 @@ class Circle implements D2ShapeInterface
|
||||||
* @return float
|
* @return float
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
|
||||||
*/
|
*/
|
||||||
public static function getRadiusByPerimeter(float $C) : float
|
public static function getRadiusByPerimeter(float $C) : float
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -99,10 +99,10 @@ class Polygon implements D2ShapeInterface
|
||||||
|
|
||||||
// Inside or ontop?
|
// Inside or ontop?
|
||||||
$countIntersect = 0;
|
$countIntersect = 0;
|
||||||
$polygon_count = count($polygon);
|
$polygonCount = count($polygon);
|
||||||
|
|
||||||
// todo: return based on highest possibility not by first match
|
// 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];
|
$vertex1 = $polygon[$i - 1];
|
||||||
$vertex2 = $polygon[$i];
|
$vertex2 = $polygon[$i];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,9 @@ class Cone implements D3ShapeInterface
|
||||||
* @return float
|
* @return float
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
|
||||||
*/
|
*/
|
||||||
public static function getHeightFromVolume(float $V, float $r) : float
|
public static function getHeightFromVolume(float $V, float $r) : float
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,9 @@ class Sphere implements D3ShapeInterface
|
||||||
* @return float
|
* @return float
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
|
||||||
*/
|
*/
|
||||||
public static function getRadiusBySurface(float $S) : float
|
public static function getRadiusBySurface(float $S) : float
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,13 @@ use phpOMS\Stdlib\Base\Enum;
|
||||||
*/
|
*/
|
||||||
abstract class NumberType extends Enum
|
abstract class NumberType extends Enum
|
||||||
{
|
{
|
||||||
/* public */ const N_INTEGER = 0;
|
/* public */ const N_INTEGER = 0;
|
||||||
/* public */ const N_NATURAL = 1;
|
/* public */ const N_NATURAL = 1;
|
||||||
/* public */ const N_EVEN = 2;
|
/* public */ const N_EVEN = 2;
|
||||||
/* public */ const N_UNEVEN = 4;
|
/* public */ const N_UNEVEN = 4;
|
||||||
/* public */ const N_PRIME = 8;
|
/* public */ const N_PRIME = 8;
|
||||||
/* public */ const N_REAL = 16;
|
/* public */ const N_REAL = 16;
|
||||||
/* public */ const N_RATIONAL = 32;
|
/* public */ const N_RATIONAL = 32;
|
||||||
/* public */ const N_IRRATIONAL = 64;
|
/* public */ const N_IRRATIONAL = 64;
|
||||||
/* public */ const N_COMPLEX = 128;
|
/* public */ const N_COMPLEX = 128;
|
||||||
}
|
}
|
||||||
|
|
@ -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
|
public static function isSelfdescribing(int $n) : bool
|
||||||
{
|
{
|
||||||
$n = (string) $n;
|
$n = (string) $n;
|
||||||
$split = str_split($n);
|
$split = str_split($n);
|
||||||
|
|
||||||
foreach ($split as $place => $value) {
|
foreach ($split as $place => $value) {
|
||||||
|
|
|
||||||
|
|
@ -28,17 +28,17 @@ use phpOMS\Math\Matrix\Exception\InvalidDimensionException;
|
||||||
class Average
|
class Average
|
||||||
{
|
{
|
||||||
|
|
||||||
/* public */ const MA3 = [1 / 3, 1 / 3];
|
/* public */ const MA3 = [1 / 3, 1 / 3];
|
||||||
/* public */ const MA5 = [0.2, 0.2, 0.2];
|
/* 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 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 MA3x3 = [1 / 3, 2 / 9, 1 / 9];
|
||||||
/* public */ const MA3x5 = [0.2, 0.2, 2 / 15, 4 / 6];
|
/* 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 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 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 MAH5 = [0.558, 0.294, -0.73];
|
||||||
/* public */ const MAH9 = [0.330, 0.267, 0.119, -0.010, -0.041];
|
/* 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 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 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.
|
* Average change.
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class Basic
|
||||||
public static function freaquency(array $values) : array
|
public static function freaquency(array $values) : array
|
||||||
{
|
{
|
||||||
$freaquency = [];
|
$freaquency = [];
|
||||||
$sum = 1;
|
$sum = 1;
|
||||||
|
|
||||||
if (!($isArray = is_array(reset($values)))) {
|
if (!($isArray = is_array(reset($values)))) {
|
||||||
$sum = array_sum($values);
|
$sum = array_sum($values);
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ class ChiSquaredDistribution
|
||||||
$sum += ($dataset[$i] - $expected[$i]) * ($dataset[$i] - $expected[$i]) / $expected[$i];
|
$sum += ($dataset[$i] - $expected[$i]) * ($dataset[$i] - $expected[$i]) / $expected[$i];
|
||||||
}
|
}
|
||||||
|
|
||||||
$P = null;
|
$p = null;
|
||||||
|
|
||||||
if ($df === 0) {
|
if ($df === 0) {
|
||||||
$df = self::getDegreesOfFreedom($dataset);
|
$df = self::getDegreesOfFreedom($dataset);
|
||||||
|
|
@ -111,14 +111,14 @@ class ChiSquaredDistribution
|
||||||
|
|
||||||
foreach (self::TABLE[$df] as $key => $value) {
|
foreach (self::TABLE[$df] as $key => $value) {
|
||||||
if ($value > $sum) {
|
if ($value > $sum) {
|
||||||
$P = $key;
|
$p = $key;
|
||||||
break;
|
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ use phpOMS\DataStorage\LockException;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.Superglobals)
|
||||||
*/
|
*/
|
||||||
class Header extends HeaderAbstract
|
class Header extends HeaderAbstract
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ use phpOMS\Uri\UriInterface;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.Superglobals)
|
||||||
*/
|
*/
|
||||||
class Request extends RequestAbstract
|
class Request extends RequestAbstract
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -100,24 +100,24 @@ class SmartDateTime extends \DateTime
|
||||||
*/
|
*/
|
||||||
public function smartModify(int $y, int $m = 0, int $d = 0, int $calendar = CAL_GREGORIAN) : SmartDateTime
|
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);
|
$yearChange = (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;
|
$yearChange = ((int) $this->format('m') - 1 + $m) < 0 && ((int) $this->format('m') - 1 + $m) % 12 === 0 ? $yearChange - 1 : $yearChange;
|
||||||
$y_new = (int) $this->format('Y') + $y + $y_change;
|
$yearNew = (int) $this->format('Y') + $y + $yearChange;
|
||||||
$m_new = ((int) $this->format('m') + $m) % 12;
|
$monthNew = ((int) $this->format('m') + $m) % 12;
|
||||||
$m_new = $m_new === 0 ? 12 : $m_new < 0 ? 12 + $m_new : $m_new;
|
$monthNew = $monthNew === 0 ? 12 : $monthNew < 0 ? 12 + $monthNew : $monthNew;
|
||||||
$d_month_old = cal_days_in_month($calendar, (int) $this->format('m'), (int) $this->format('Y'));
|
$dayMonthOld = 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);
|
$dayMonthNew = cal_days_in_month($calendar, $monthNew, $yearNew);
|
||||||
$d_old = (int) $this->format('d');
|
$dayOld = (int) $this->format('d');
|
||||||
|
|
||||||
if ($d_old > $d_month_new) {
|
if ($dayOld > $dayMonthNew) {
|
||||||
$d_new = $d_month_new;
|
$dayNew = $dayMonthNew;
|
||||||
} elseif ($d_old < $d_month_new && $d_old === $d_month_old) {
|
} elseif ($dayOld < $dayMonthNew && $dayOld === $dayMonthOld) {
|
||||||
$d_new = $d_month_new;
|
$dayNew = $dayMonthNew;
|
||||||
} else {
|
} else {
|
||||||
$d_new = $d_old;
|
$dayNew = $dayOld;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setDate($y_new, $m_new, $d_new);
|
$this->setDate($yearNew, $monthNew, $dayNew);
|
||||||
|
|
||||||
if ($d !== 0) {
|
if ($d !== 0) {
|
||||||
$this->modify($d . ' day');
|
$this->modify($d . ' day');
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,7 @@ class File extends FileAbstract implements FileInterface
|
||||||
|
|
||||||
$exists = self::ftpExists($con, $http->getPath());
|
$exists = self::ftpExists($con, $http->getPath());
|
||||||
|
|
||||||
if (
|
if ((ContentPutMode::hasFlag($mode, ContentPutMode::APPEND) && $exists)
|
||||||
(ContentPutMode::hasFlag($mode, ContentPutMode::APPEND) && $exists)
|
|
||||||
|| (ContentPutMode::hasFlag($mode, ContentPutMode::PREPEND) && $exists)
|
|| (ContentPutMode::hasFlag($mode, ContentPutMode::PREPEND) && $exists)
|
||||||
|| (ContentPutMode::hasFlag($mode, ContentPutMode::REPLACE) && $exists)
|
|| (ContentPutMode::hasFlag($mode, ContentPutMode::REPLACE) && $exists)
|
||||||
|| (!$exists && ContentPutMode::hasFlag($mode, ContentPutMode::CREATE))
|
|| (!$exists && ContentPutMode::hasFlag($mode, ContentPutMode::CREATE))
|
||||||
|
|
@ -124,10 +123,10 @@ class File extends FileAbstract implements FileInterface
|
||||||
*/
|
*/
|
||||||
public static function get(string $path) : string
|
public static function get(string $path) : string
|
||||||
{
|
{
|
||||||
$temp = fopen('php://temp', 'r+');
|
$temp = fopen('php://temp', 'r+');
|
||||||
$http = new Http($path);
|
$http = new Http($path);
|
||||||
$content = '';
|
$content = '';
|
||||||
$con = self::ftpConnect($http);
|
$con = self::ftpConnect($http);
|
||||||
|
|
||||||
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);
|
rewind($temp);
|
||||||
|
|
@ -168,8 +167,8 @@ class File extends FileAbstract implements FileInterface
|
||||||
*/
|
*/
|
||||||
public static function exists(string $path) : bool
|
public static function exists(string $path) : bool
|
||||||
{
|
{
|
||||||
$http = new Http($path);
|
$http = new Http($path);
|
||||||
$con = self::ftpConnect($http);
|
$con = self::ftpConnect($http);
|
||||||
$exists = self::ftpExists($con, $http->getPath());
|
$exists = self::ftpExists($con, $http->getPath());
|
||||||
|
|
||||||
fclose($con);
|
fclose($con);
|
||||||
|
|
@ -206,8 +205,8 @@ class File extends FileAbstract implements FileInterface
|
||||||
*/
|
*/
|
||||||
public static function changed(string $path) : \DateTime
|
public static function changed(string $path) : \DateTime
|
||||||
{
|
{
|
||||||
$http = new Http($path);
|
$http = new Http($path);
|
||||||
$con = self::ftpConnect($http);
|
$con = self::ftpConnect($http);
|
||||||
$changed = new \DateTime();
|
$changed = new \DateTime();
|
||||||
|
|
||||||
$changed->setTimestamp(ftp_mdtm($con, $http->getPath()));
|
$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
|
public static function size(string $path, bool $recursive = true) : int
|
||||||
{
|
{
|
||||||
$http = new Http($path);
|
$http = new Http($path);
|
||||||
$con = self::ftpConnect($http);
|
$con = self::ftpConnect($http);
|
||||||
|
|
||||||
if (!self::exists($http->getPath())) {
|
if (!self::exists($http->getPath())) {
|
||||||
throw new PathException($path);
|
throw new PathException($path);
|
||||||
|
|
@ -241,8 +240,8 @@ class File extends FileAbstract implements FileInterface
|
||||||
*/
|
*/
|
||||||
public static function owner(string $path) : int
|
public static function owner(string $path) : int
|
||||||
{
|
{
|
||||||
$http = new Http($path);
|
$http = new Http($path);
|
||||||
$con = self::ftpConnect($http);
|
$con = self::ftpConnect($http);
|
||||||
$owner = self::parseFtpFileData($con, $path)['user'] ?? '';
|
$owner = self::parseFtpFileData($con, $path)['user'] ?? '';
|
||||||
|
|
||||||
fclose($con);
|
fclose($con);
|
||||||
|
|
@ -255,8 +254,8 @@ class File extends FileAbstract implements FileInterface
|
||||||
*/
|
*/
|
||||||
public static function permission(string $path) : int
|
public static function permission(string $path) : int
|
||||||
{
|
{
|
||||||
$http = new Http($path);
|
$http = new Http($path);
|
||||||
$con = self::ftpConnect($http);
|
$con = self::ftpConnect($http);
|
||||||
$permission = (int) self::parseFtpFileData($con, $path)['permission'] ?? 0;
|
$permission = (int) self::parseFtpFileData($con, $path)['permission'] ?? 0;
|
||||||
|
|
||||||
fclose($con);
|
fclose($con);
|
||||||
|
|
@ -274,10 +273,10 @@ class File extends FileAbstract implements FileInterface
|
||||||
$chunks = preg_split("/\s+/", $fileData);
|
$chunks = preg_split("/\s+/", $fileData);
|
||||||
|
|
||||||
$items['permission'] = $chunks[0];
|
$items['permission'] = $chunks[0];
|
||||||
$items['user'] = $chunks[2];
|
$items['user'] = $chunks[2];
|
||||||
$items['group'] = $chunks[3];
|
$items['group'] = $chunks[3];
|
||||||
$items['size'] = $chunks[4];
|
$items['size'] = $chunks[4];
|
||||||
$items['type'] = $chunks[0][0] === 'd' ? 'directory' : 'file';
|
$items['type'] = $chunks[0][0] === 'd' ? 'directory' : 'file';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +335,7 @@ class File extends FileAbstract implements FileInterface
|
||||||
{
|
{
|
||||||
// todo: handle different ftp connections AND local to ftp
|
// todo: handle different ftp connections AND local to ftp
|
||||||
$http = new Http($to);
|
$http = new Http($to);
|
||||||
$con = self::ftpConnect($http);
|
$con = self::ftpConnect($http);
|
||||||
|
|
||||||
if (!self::ftpExists($con, $from)) {
|
if (!self::ftpExists($con, $from)) {
|
||||||
throw new PathException($from);
|
throw new PathException($from);
|
||||||
|
|
@ -364,7 +363,7 @@ class File extends FileAbstract implements FileInterface
|
||||||
public static function delete(string $path) : bool
|
public static function delete(string $path) : bool
|
||||||
{
|
{
|
||||||
$http = new Http($path);
|
$http = new Http($path);
|
||||||
$con = self::ftpConnect($http);
|
$con = self::ftpConnect($http);
|
||||||
|
|
||||||
if (!self::ftpExists($con, $path)) {
|
if (!self::ftpExists($con, $path)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace phpOMS\System\File\Ftp;
|
namespace phpOMS\System\File\Ftp;
|
||||||
|
|
||||||
use phpOMS\System\File\StorageAbstract;
|
use phpOMS\System\File\StorageAbstract;
|
||||||
use phpOMS\System\File\PathException;
|
use phpOMS\System\File\PathException;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,8 +142,8 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
*/
|
*/
|
||||||
public function addNode($file) : bool
|
public function addNode($file) : bool
|
||||||
{
|
{
|
||||||
$this->count += $file->getCount();
|
$this->count += $file->getCount();
|
||||||
$this->size += $file->getSize();
|
$this->size += $file->getSize();
|
||||||
$this->nodes[$file->getName()] = $file;
|
$this->nodes[$file->getName()] = $file;
|
||||||
|
|
||||||
return $file->createNode();
|
return $file->createNode();
|
||||||
|
|
@ -158,10 +158,10 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
throw new PathException($dir);
|
throw new PathException($dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
$countSize = 0;
|
$countSize = 0;
|
||||||
$dir_array = scandir($dir);
|
$directories = scandir($dir);
|
||||||
|
|
||||||
foreach ($dir_array as $key => $filename) {
|
foreach ($directories as $key => $filename) {
|
||||||
if ($filename === ".." || $filename === ".") {
|
if ($filename === ".." || $filename === ".") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -186,8 +186,8 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
throw new PathException($path);
|
throw new PathException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$size = 0;
|
$size = 0;
|
||||||
$files = scandir($path);
|
$files = scandir($path);
|
||||||
$ignore[] = '.';
|
$ignore[] = '.';
|
||||||
$ignore[] = '..';
|
$ignore[] = '..';
|
||||||
|
|
||||||
|
|
@ -411,7 +411,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
{
|
{
|
||||||
if (isset($this->nodes[$name])) {
|
if (isset($this->nodes[$name])) {
|
||||||
$this->count -= $this->nodes[$name]->getCount();
|
$this->count -= $this->nodes[$name]->getCount();
|
||||||
$this->size -= $this->nodes[$name]->getSize();
|
$this->size -= $this->nodes[$name]->getSize();
|
||||||
|
|
||||||
unset($this->nodes[$name]);
|
unset($this->nodes[$name]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,7 @@ class File extends FileAbstract implements FileInterface
|
||||||
{
|
{
|
||||||
$exists = file_exists($path);
|
$exists = file_exists($path);
|
||||||
|
|
||||||
if (
|
if ((ContentPutMode::hasFlag($mode, ContentPutMode::APPEND) && $exists)
|
||||||
(ContentPutMode::hasFlag($mode, ContentPutMode::APPEND) && $exists)
|
|
||||||
|| (ContentPutMode::hasFlag($mode, ContentPutMode::PREPEND) && $exists)
|
|| (ContentPutMode::hasFlag($mode, ContentPutMode::PREPEND) && $exists)
|
||||||
|| (ContentPutMode::hasFlag($mode, ContentPutMode::REPLACE) && $exists)
|
|| (ContentPutMode::hasFlag($mode, ContentPutMode::REPLACE) && $exists)
|
||||||
|| (!$exists && ContentPutMode::hasFlag($mode, ContentPutMode::CREATE))
|
|| (!$exists && ContentPutMode::hasFlag($mode, ContentPutMode::CREATE))
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace phpOMS\System\File\Local;
|
namespace phpOMS\System\File\Local;
|
||||||
|
|
||||||
use phpOMS\System\File\ContainerInterface;
|
use phpOMS\System\File\ContainerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
1958
System/MimeType.php
1958
System/MimeType.php
File diff suppressed because it is too large
Load Diff
|
|
@ -79,19 +79,19 @@ class SystemUtils
|
||||||
*/
|
*/
|
||||||
public static function getRAMUsage() : int
|
public static function getRAMUsage() : int
|
||||||
{
|
{
|
||||||
$memusage = 0;
|
$memUsage = 0;
|
||||||
|
|
||||||
if (stristr(PHP_OS, 'LINUX')) {
|
if (stristr(PHP_OS, 'LINUX')) {
|
||||||
$free = shell_exec('free');
|
$free = shell_exec('free');
|
||||||
$free = (string) trim($free);
|
$free = (string) trim($free);
|
||||||
$free_arr = explode("\n", $free);
|
$freeArr = explode("\n", $free);
|
||||||
$mem = explode(" ", $free_arr[1]);
|
$mem = explode(" ", $freeArr[1]);
|
||||||
$mem = array_filter($mem);
|
$mem = array_filter($mem);
|
||||||
$mem = array_merge($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
|
public static function getCpuUsage() : int
|
||||||
{
|
{
|
||||||
$cpuusage = 0;
|
$cpuUsage = 0;
|
||||||
|
|
||||||
if (stristr(PHP_OS, 'WIN') !== false) {
|
if (stristr(PHP_OS, 'WIN') !== false) {
|
||||||
$cpuusage = null;
|
$cpuUsage = null;
|
||||||
exec('wmic cpu get LoadPercentage', $cpuusage);
|
exec('wmic cpu get LoadPercentage', $cpuUsage);
|
||||||
$cpuusage = $cpuusage[1];
|
$cpuUsage = $cpuUsage[1];
|
||||||
} elseif (stristr(PHP_OS, 'LINUX') !== false) {
|
} elseif (stristr(PHP_OS, 'LINUX') !== false) {
|
||||||
$cpuusage = \sys_getloadavg()[0] * 100;
|
$cpuUsage = \sys_getloadavg()[0] * 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) $cpuusage;
|
return (int) $cpuUsage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ use phpOMS\Utils\StringUtils;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.Superglobals)
|
||||||
*/
|
*/
|
||||||
class Http implements UriInterface
|
class Http implements UriInterface
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@ use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
*/
|
*/
|
||||||
abstract class C128Abstract
|
abstract class C128Abstract
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
*/
|
*/
|
||||||
class C128a extends C128Abstract
|
class C128a extends C128Abstract
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
*/
|
*/
|
||||||
class C128b extends C128Abstract
|
class C128b extends C128Abstract
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
*/
|
*/
|
||||||
class C128c extends C128Abstract
|
class C128c extends C128Abstract
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
*/
|
*/
|
||||||
class C25 extends C128Abstract
|
class C25 extends C128Abstract
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
*/
|
*/
|
||||||
class C39 extends C128Abstract
|
class C39 extends C128Abstract
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ namespace phpOMS\Utils\Barcode;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
|
||||||
*/
|
*/
|
||||||
class Codebar extends C128Abstract
|
class Codebar extends C128Abstract
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -134,8 +134,8 @@ class Text
|
||||||
$words = self::$wordsWest;
|
$words = self::$wordsWest;
|
||||||
}
|
}
|
||||||
|
|
||||||
$punctuation = $this->generatePunctuation($length);
|
$punctuation = $this->generatePunctuation($length);
|
||||||
$punctuation_count = array_count_values(
|
$punctuationCount = array_count_values(
|
||||||
array_map(
|
array_map(
|
||||||
function ($item) {
|
function ($item) {
|
||||||
return $item[1];
|
return $item[1];
|
||||||
|
|
@ -144,7 +144,7 @@ class Text
|
||||||
)
|
)
|
||||||
) + ['.' => 0, '!' => 0, '?' => 0];
|
) + ['.' => 0, '!' => 0, '?' => 0];
|
||||||
|
|
||||||
$this->sentences = $punctuation_count['.'] + $punctuation_count['!'] + $punctuation_count['?'];
|
$this->sentences = $punctuationCount['.'] + $punctuationCount['!'] + $punctuationCount['?'];
|
||||||
|
|
||||||
if ($this->hasParagraphs) {
|
if ($this->hasParagraphs) {
|
||||||
$paragraph = $this->generateParagraph($this->sentences);
|
$paragraph = $this->generateParagraph($this->sentences);
|
||||||
|
|
@ -233,16 +233,16 @@ class Text
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle comma */
|
/* Handle comma */
|
||||||
$comma_here = (rand(0, 100) <= $probComma * 100 && $sentenceLength >= 2 * $minCommaSpacing ? true : false);
|
$commaHere = (rand(0, 100) <= $probComma * 100 && $sentenceLength >= 2 * $minCommaSpacing ? true : false);
|
||||||
$posComma = [];
|
$posComma = [];
|
||||||
|
|
||||||
if ($comma_here) {
|
if ($commaHere) {
|
||||||
$posComma[] = rand($minCommaSpacing, $sentenceLength - $minCommaSpacing);
|
$posComma[] = rand($minCommaSpacing, $sentenceLength - $minCommaSpacing);
|
||||||
$punctuation[] = [$i + $posComma[0], ','];
|
$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);
|
$posComma[] = rand($posComma[0] + $minCommaSpacing, $sentenceLength - $minCommaSpacing);
|
||||||
$punctuation[] = [$i + $posComma[1], ','];
|
$punctuation[] = [$i + $posComma[1], ','];
|
||||||
}
|
}
|
||||||
|
|
@ -251,16 +251,16 @@ class Text
|
||||||
$i += $sentenceLength;
|
$i += $sentenceLength;
|
||||||
|
|
||||||
/* Handle sentence ending */
|
/* 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, '.'];
|
$punctuation[] = [$i, '.'];
|
||||||
continue;
|
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, '!'];
|
$punctuation[] = [$i, '!'];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ namespace phpOMS\Utils;
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @link http://website.orange-management.de
|
* @link http://website.orange-management.de
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
|
||||||
*/
|
*/
|
||||||
class StringUtils
|
class StringUtils
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -44,12 +44,12 @@ abstract class CreditCard extends ValidatorAbstract
|
||||||
$value = preg_replace('/\D/', '', $value);
|
$value = preg_replace('/\D/', '', $value);
|
||||||
|
|
||||||
// Set the string length and parity
|
// Set the string length and parity
|
||||||
$number_length = strlen($value);
|
$numberLength = strlen($value);
|
||||||
$parity = $number_length % 2;
|
$parity = $numberLength % 2;
|
||||||
|
|
||||||
// Loop through each digit and do the maths
|
// Loop through each digit and do the maths
|
||||||
$total = 0;
|
$total = 0;
|
||||||
for ($i = 0; $i < $number_length; $i++) {
|
for ($i = 0; $i < $numberLength; $i++) {
|
||||||
$digit = $value[$i];
|
$digit = $value[$i];
|
||||||
// Multiply alternate digits by two
|
// Multiply alternate digits by two
|
||||||
if ($i % 2 == $parity) {
|
if ($i % 2 == $parity) {
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@ class GATest extends \PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
public function testTsp()
|
public function testTsp()
|
||||||
{
|
{
|
||||||
$cities = [new City()];
|
$cities = [new City()];
|
||||||
$cityPool = new CityPool($cities);
|
$cityPool = new CityPool($cities);
|
||||||
$ga = new Ga($cityPool);
|
$ga = new Ga($cityPool);
|
||||||
|
|
||||||
$basePopulation = new Population($cityPool, 1000, true);
|
$basePopulation = new Population($cityPool, 1000, true);
|
||||||
$population = $ga->evolvePopulation($basePopulation);
|
$population = $ga->evolvePopulation($basePopulation);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ class StringUtilsTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testStrings()
|
public function testStrings()
|
||||||
{
|
{
|
||||||
$haystack = [];
|
$haystack = [];
|
||||||
$outOfBounds = false;
|
$outOfBounds = false;
|
||||||
$randomness = 0;
|
$randomness = 0;
|
||||||
|
|
||||||
for ($i = 0; $i < 10000; $i++) {
|
for ($i = 0; $i < 10000; $i++) {
|
||||||
$random = StringUtils::generateString(5, 12, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_?><|;"');
|
$random = StringUtils::generateString(5, 12, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_?><|;"');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user