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

@ -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;
} }
} }

View File

@ -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
{ {

View File

@ -18,6 +18,7 @@ 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)

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

@ -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 * @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
{ {

View File

@ -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
{ {

View File

@ -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
* *

View File

@ -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()
{
} }

View File

@ -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
{ {

View File

@ -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)
* *

View File

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

View File

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

View File

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

View File

@ -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;
} }

View File

@ -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;

View File

@ -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());

View File

@ -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()
{ {

View File

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

View File

@ -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.');
} }

View File

@ -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());

View File

@ -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;

View File

@ -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;
/** /**

View File

@ -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;
/** /**

View File

@ -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;
/** /**

View File

@ -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;
/** /**

View File

@ -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;
/** /**

View File

@ -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
{ {
@ -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);
} }
/** /**

View File

@ -24,6 +24,8 @@ 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
{ {

View File

@ -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;

View File

@ -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
{ {

View File

@ -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];

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -43,7 +43,7 @@ class Numbers
} }
} }
return $sum == $n; return $sum === $n;
} }
/** /**

View File

@ -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];
} }
/** /**

View File

@ -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
{ {

View File

@ -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
{ {

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 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');

View File

@ -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))

View File

@ -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;

View File

@ -159,9 +159,9 @@ class Directory extends FileAbstract implements DirectoryInterface
} }
$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;
} }

View File

@ -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))

View File

@ -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;
/** /**

View File

@ -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;
} }
} }

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -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
{ {

View File

@ -135,7 +135,7 @@ class Text
} }
$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;
} }

View File

@ -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
{ {

View File

@ -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) {