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

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

@ -18,6 +18,7 @@ use phpOMS\Math\Statistic\Average;
class ARIMA
{
private $data = [];
private $order = 0;
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
* @link http://website.orange-management.de
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
class Loan
{

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
*

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

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,6 +55,8 @@ class Metrics {
* @return int
*
* @since 1.0.0
*
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
*/
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
* @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

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

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

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

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

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

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

View File

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

View File

@ -57,14 +57,14 @@ class Fibunacci
return $start;
}
$old_1 = $start;
$old_2 = $start;
$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

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

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

@ -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];
}
$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))

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

@ -159,9 +159,9 @@ class Directory extends FileAbstract implements DirectoryInterface
}
$countSize = 0;
$dir_array = scandir($dir);
$directories = scandir($dir);
foreach ($dir_array as $key => $filename) {
foreach ($directories as $key => $filename) {
if ($filename === ".." || $filename === ".") {
continue;
}

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

View File

@ -13,6 +13,7 @@
declare(strict_types = 1);
namespace phpOMS\System\File\Local;
use phpOMS\System\File\ContainerInterface;
/**

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

@ -135,7 +135,7 @@ class Text
}
$punctuation = $this->generatePunctuation($length);
$punctuation_count = array_count_values(
$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);
$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) {