mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-01 10:28:40 +00:00
Merge pull request #17 from Orange-Management/scrutinizer-patch-1
Scrutinizer Auto-Fixes
This commit is contained in:
commit
bde9db585e
|
|
@ -364,7 +364,7 @@ class Account
|
||||||
*/
|
*/
|
||||||
public function setEmail(string $email)
|
public function setEmail(string $email)
|
||||||
{
|
{
|
||||||
if(!Email::isValid($email)) {
|
if (!Email::isValid($email)) {
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -383,7 +383,7 @@ class Account
|
||||||
*/
|
*/
|
||||||
public function setStatus(int $status)
|
public function setStatus(int $status)
|
||||||
{
|
{
|
||||||
if(!AccountStatus::isValidValue($status)) {
|
if (!AccountStatus::isValidValue($status)) {
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -402,7 +402,7 @@ class Account
|
||||||
*/
|
*/
|
||||||
public function setType(int $type)
|
public function setType(int $type)
|
||||||
{
|
{
|
||||||
if(!AccountType::isValidValue($type)) {
|
if (!AccountType::isValidValue($type)) {
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ abstract class SettingsAbstract implements OptionsInterface
|
||||||
{
|
{
|
||||||
$this->setOptions($options);
|
$this->setOptions($options);
|
||||||
|
|
||||||
if($store) {
|
if ($store) {
|
||||||
// save to db
|
// save to db
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class CookieJar
|
||||||
|
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
if(self::$isLocked) {
|
if (self::$isLocked) {
|
||||||
throw new \Exception('Already locked');
|
throw new \Exception('Already locked');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1000,11 +1000,11 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
$query = new Builder($this->db);
|
$query = new Builder($this->db);
|
||||||
$query->prefix($this->db->getPrefix());
|
$query->prefix($this->db->getPrefix());
|
||||||
|
|
||||||
if($relations === RelationType::ALL) {
|
if ($relations === RelationType::ALL) {
|
||||||
$query->select($value['table'] . '.' . $value['src'])
|
$query->select($value['table'] . '.' . $value['src'])
|
||||||
->from($value['table'])
|
->from($value['table'])
|
||||||
->where($value['table'] . '.' . $value['dst'], '=', $primaryKey);
|
->where($value['table'] . '.' . $value['dst'], '=', $primaryKey);
|
||||||
} elseif($relations === RelationType::NEWEST) {
|
} elseif ($relations === RelationType::NEWEST) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SELECT c.*, p1.*
|
SELECT c.*, p1.*
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ abstract class GrammarAbstract
|
||||||
implode(' ',
|
implode(' ',
|
||||||
array_filter(
|
array_filter(
|
||||||
$this->compileComponents($query),
|
$this->compileComponents($query),
|
||||||
function ($value) {
|
function($value) {
|
||||||
return (string) $value !== '';
|
return (string) $value !== '';
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -135,7 +135,7 @@ abstract class GrammarAbstract
|
||||||
{
|
{
|
||||||
// todo: move remaining * test also here not just if .* but also if * (should be done in else?)
|
// todo: move remaining * test also here not just if .* but also if * (should be done in else?)
|
||||||
if (count($split = explode('.', $system)) == 2) {
|
if (count($split = explode('.', $system)) == 2) {
|
||||||
if($split[1] === '*') {
|
if ($split[1] === '*') {
|
||||||
$system = $split[1];
|
$system = $split[1];
|
||||||
} else {
|
} else {
|
||||||
$system = $this->compileSystem($split[1]);
|
$system = $this->compileSystem($split[1]);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ class HttpSession implements SessionInterface
|
||||||
*/
|
*/
|
||||||
public function __construct(int $liftetime = 3600, $sid = false)
|
public function __construct(int $liftetime = 3600, $sid = false)
|
||||||
{
|
{
|
||||||
if(self::$isLocked) {
|
if (self::$isLocked) {
|
||||||
throw new \Exception('Already locked');
|
throw new \Exception('Already locked');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +110,7 @@ class HttpSession implements SessionInterface
|
||||||
*/
|
*/
|
||||||
public function set($key, $value, bool $overwrite = true) : bool
|
public function set($key, $value, bool $overwrite = true) : bool
|
||||||
{
|
{
|
||||||
if($overwrite || !isset($this->sessionData[$key])) {
|
if ($overwrite || !isset($this->sessionData[$key])) {
|
||||||
$this->sessionData[$key] = $value;
|
$this->sessionData[$key] = $value;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class SmartDateTime extends \DateTime
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
const FORMAT = 'Y-m-d hh:mm:ss';
|
const FORMAT = 'Y-m-d hh:mm:ss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default timezone
|
* Default timezone
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ class L11nManager
|
||||||
*/
|
*/
|
||||||
public function loadLanguage(string $language, string $from, array $files)
|
public function loadLanguage(string $language, string $from, array $files)
|
||||||
{
|
{
|
||||||
if(!isset($files[$from])) {
|
if (!isset($files[$from])) {
|
||||||
throw new \Exception('Unexpected language key: ' . $from);
|
throw new \Exception('Unexpected language key: ' . $from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ class Localization
|
||||||
*/
|
*/
|
||||||
public function setCountry(string $country)
|
public function setCountry(string $country)
|
||||||
{
|
{
|
||||||
if(!ISO3166Enum::isValidValue($country)) {
|
if (!ISO3166Enum::isValidValue($country)) {
|
||||||
throw new InvalidEnumValue($country);
|
throw new InvalidEnumValue($country);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ class Localization
|
||||||
*/
|
*/
|
||||||
public function setTimezone(string $timezone)
|
public function setTimezone(string $timezone)
|
||||||
{
|
{
|
||||||
if(!TimeZoneEnumArray::isValidValue($timezone)) {
|
if (!TimeZoneEnumArray::isValidValue($timezone)) {
|
||||||
throw new InvalidEnumValue($timezone);
|
throw new InvalidEnumValue($timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ class Localization
|
||||||
*/
|
*/
|
||||||
public function setLanguage(string $language)
|
public function setLanguage(string $language)
|
||||||
{
|
{
|
||||||
if(!ISO639x1Enum::isValidValue($language)) {
|
if (!ISO639x1Enum::isValidValue($language)) {
|
||||||
throw new InvalidEnumValue($language);
|
throw new InvalidEnumValue($language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,7 +233,7 @@ class Localization
|
||||||
*/
|
*/
|
||||||
public function setCurrency(string $currency)
|
public function setCurrency(string $currency)
|
||||||
{
|
{
|
||||||
if(!ISO4217Enum::isValidValue($currency)) {
|
if (!ISO4217Enum::isValidValue($currency)) {
|
||||||
throw new InvalidEnumValue($currency);
|
throw new InvalidEnumValue($currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -290,13 +290,13 @@ class FileLogger implements LoggerInterface
|
||||||
{
|
{
|
||||||
$this->fp = fopen($this->path, 'a');
|
$this->fp = fopen($this->path, 'a');
|
||||||
|
|
||||||
if($this->fp !== false) {
|
if ($this->fp !== false) {
|
||||||
fwrite($this->fp, $message . "\n");
|
fwrite($this->fp, $message . "\n");
|
||||||
fclose($this->fp);
|
fclose($this->fp);
|
||||||
$this->fp = false;
|
$this->fp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(self::$verbose) {
|
if (self::$verbose) {
|
||||||
echo $message . "\n";
|
echo $message . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class PointPolygonIntersection
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inside or ontop?
|
// Inside or ontop?
|
||||||
$countIntersect = 0;
|
$countIntersect = 0;
|
||||||
$vertices_count = count($vertices);
|
$vertices_count = count($vertices);
|
||||||
|
|
||||||
// todo: return based on highest possibility not by first match
|
// todo: return based on highest possibility not by first match
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,12 @@ class Fibunacci
|
||||||
{
|
{
|
||||||
public static function isFibunacci(int $n)
|
public static function isFibunacci(int $n)
|
||||||
{
|
{
|
||||||
return Functions::isSquare(5*$n**2+4) || Functions::isSquare(5*$n**2-4);
|
return Functions::isSquare(5 * $n**2 + 4) || Functions::isSquare(5 * $n**2 - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fibunacci(int $n, int $start = 1) : int
|
public static function fibunacci(int $n, int $start = 1) : int
|
||||||
{
|
{
|
||||||
if($n < 2) {
|
if ($n < 2) {
|
||||||
return 0;
|
return 0;
|
||||||
} elseif ($n < 4) {
|
} elseif ($n < 4) {
|
||||||
return $start;
|
return $start;
|
||||||
|
|
@ -57,6 +57,6 @@ class Fibunacci
|
||||||
|
|
||||||
public static function binet(int $n) : int
|
public static function binet(int $n) : int
|
||||||
{
|
{
|
||||||
return (int) (((1+sqrt(5))**$n - (1-sqrt(5))**$n)/(2**$n * sqrt(5)));
|
return (int) (((1 + sqrt(5))**$n - (1 - sqrt(5))**$n) / (2**$n * sqrt(5)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -129,13 +129,13 @@ class Functions
|
||||||
*/
|
*/
|
||||||
public static function ackermann(int $m, int $n) : int
|
public static function ackermann(int $m, int $n) : int
|
||||||
{
|
{
|
||||||
if($m === 0) {
|
if ($m === 0) {
|
||||||
return $n+1;
|
return $n + 1;
|
||||||
} elseif($n === 0) {
|
} elseif ($n === 0) {
|
||||||
return self::ackermann($m-1, 1);
|
return self::ackermann($m - 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ackermann($m-1, ackermann($m, $n-1));
|
return ackermann($m - 1, ackermann($m, $n - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -149,7 +149,7 @@ class Functions
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public static function invMod($a, $n){
|
public static function invMod($a, $n) {
|
||||||
if ($n < 0) {
|
if ($n < 0) {
|
||||||
$n = -$n;
|
$n = -$n;
|
||||||
}
|
}
|
||||||
|
|
@ -164,12 +164,12 @@ class Functions
|
||||||
$nr = $a % $n;
|
$nr = $a % $n;
|
||||||
|
|
||||||
while ($nr != 0) {
|
while ($nr != 0) {
|
||||||
$quot = (int) ($r/$nr);
|
$quot = (int) ($r / $nr);
|
||||||
$tmp = $nt;
|
$tmp = $nt;
|
||||||
$nt = $t - $quot*$nt;
|
$nt = $t - $quot * $nt;
|
||||||
$t = $tmp;
|
$t = $tmp;
|
||||||
$tmp = $nr;
|
$tmp = $nr;
|
||||||
$nr = $r - $quot*$nr;
|
$nr = $r - $quot * $nr;
|
||||||
$r = $tmp;
|
$r = $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,14 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
$this->n = $n;
|
$this->n = $n;
|
||||||
$this->m = $m;
|
$this->m = $m;
|
||||||
|
|
||||||
for($i = 0; $i < $m; $i++) {
|
for ($i = 0; $i < $m; $i++) {
|
||||||
$this->matrix[$i] = array_fill(0, $n, 0);
|
$this->matrix[$i] = array_fill(0, $n, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMatrix(array $matrix)
|
public function setMatrix(array $matrix)
|
||||||
{
|
{
|
||||||
if($this->m !== count($matrix) || $this->n !== count($matrix[0])) {
|
if ($this->m !== count($matrix) || $this->n !== count($matrix[0])) {
|
||||||
throw new \Exception('Dimension');
|
throw new \Exception('Dimension');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,9 +53,9 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
|
|
||||||
public function mult($value) : Matrix
|
public function mult($value) : Matrix
|
||||||
{
|
{
|
||||||
if($value instanceOf Matrix) {
|
if ($value instanceOf Matrix) {
|
||||||
return $this->multMatrix($value);
|
return $this->multMatrix($value);
|
||||||
} elseif(is_scalar($value)) {
|
} elseif (is_scalar($value)) {
|
||||||
return $this->multScalar($value);
|
return $this->multScalar($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +65,7 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
$nDim = $matrix->getN();
|
$nDim = $matrix->getN();
|
||||||
$mDim = $matrix->getM();
|
$mDim = $matrix->getM();
|
||||||
|
|
||||||
if($this->n !== $mDim) {
|
if ($this->n !== $mDim) {
|
||||||
throw new \Exception('Dimension');
|
throw new \Exception('Dimension');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,11 +73,11 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
$newMatrix = new Matrix($this->m, $nDim);
|
$newMatrix = new Matrix($this->m, $nDim);
|
||||||
$newMatrixArr = $newMatrix->getMatrix();
|
$newMatrixArr = $newMatrix->getMatrix();
|
||||||
|
|
||||||
for($i = 0; $i < $this->m; $i++) { // Row of $this
|
for ($i = 0; $i < $this->m; $i++) { // Row of $this
|
||||||
for($c = 0; $c < $nDim; $c++) { // Column of $matrix
|
for ($c = 0; $c < $nDim; $c++) { // Column of $matrix
|
||||||
$temp = 0;
|
$temp = 0;
|
||||||
|
|
||||||
for($j = 0; $j < $mDim; $i++) { // Row of $matrix
|
for ($j = 0; $j < $mDim; $i++) { // Row of $matrix
|
||||||
$temp += $this->matrix[$i][$j] * $matrixArr[$j][$c];
|
$temp += $this->matrix[$i][$j] * $matrixArr[$j][$c];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,8 +94,8 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
{
|
{
|
||||||
$newMatrixArr = $this->matrix;
|
$newMatrixArr = $this->matrix;
|
||||||
|
|
||||||
foreach($newMatrixArr as $i => $vector) {
|
foreach ($newMatrixArr as $i => $vector) {
|
||||||
foreach($vector as $j => $value) {
|
foreach ($vector as $j => $value) {
|
||||||
$newMatrixArr[$i][$j] *= $value;
|
$newMatrixArr[$i][$j] *= $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -108,33 +108,33 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
|
|
||||||
public function add($value) : Matrix
|
public function add($value) : Matrix
|
||||||
{
|
{
|
||||||
if($value instanceOf Matrix) {
|
if ($value instanceOf Matrix) {
|
||||||
return $this->addMatrix($value);
|
return $this->addMatrix($value);
|
||||||
} elseif(is_scalar($value)) {
|
} elseif (is_scalar($value)) {
|
||||||
return $this->addScalar($value);
|
return $this->addScalar($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sub($value) : Matrix
|
public function sub($value) : Matrix
|
||||||
{
|
{
|
||||||
if($value instanceOf Matrix) {
|
if ($value instanceOf Matrix) {
|
||||||
return $this->add($this->multMatrix(-1));
|
return $this->add($this->multMatrix(-1));
|
||||||
} elseif(is_scalar($value)) {
|
} elseif (is_scalar($value)) {
|
||||||
return $this->addScalar(-$value);
|
return $this->addScalar(-$value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addMatrix(Matrix $value) : Matrix
|
private function addMatrix(Matrix $value) : Matrix
|
||||||
{
|
{
|
||||||
if($this->m !== $value->getM() || $this->n !== $value->getN()) {
|
if ($this->m !== $value->getM() || $this->n !== $value->getN()) {
|
||||||
throw new \Exception('Dimension');
|
throw new \Exception('Dimension');
|
||||||
}
|
}
|
||||||
|
|
||||||
$matrixArr = $value->getMatrix();
|
$matrixArr = $value->getMatrix();
|
||||||
$newMatrixArr = $this->matrix;
|
$newMatrixArr = $this->matrix;
|
||||||
|
|
||||||
foreach($newMatrixArr as $i => $vector) {
|
foreach ($newMatrixArr as $i => $vector) {
|
||||||
foreach($vector as $j => $value) {
|
foreach ($vector as $j => $value) {
|
||||||
$newMatrixArr[$i][$j] += $matrixArr[$i][$j];
|
$newMatrixArr[$i][$j] += $matrixArr[$i][$j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,8 +149,8 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
{
|
{
|
||||||
$newMatrixArr = $this->matrix;
|
$newMatrixArr = $this->matrix;
|
||||||
|
|
||||||
foreach($newMatrixArr as $i => $vector) {
|
foreach ($newMatrixArr as $i => $vector) {
|
||||||
foreach($vector as $j => $value) {
|
foreach ($vector as $j => $value) {
|
||||||
$newMatrixArr[$i][$j] += $value;
|
$newMatrixArr[$i][$j] += $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -184,11 +184,11 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
|
|
||||||
public function inverse(int $algorithm = InversionType::GAUSS_JORDAN) : Matrix
|
public function inverse(int $algorithm = InversionType::GAUSS_JORDAN) : Matrix
|
||||||
{
|
{
|
||||||
if($this->n !== $this->m) {
|
if ($this->n !== $this->m) {
|
||||||
throw new \Exception('Dimension');
|
throw new \Exception('Dimension');
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($algorithm) {
|
switch ($algorithm) {
|
||||||
case InversionType::GAUSS_JORDAN:
|
case InversionType::GAUSS_JORDAN:
|
||||||
return $this->inverseGaussJordan();
|
return $this->inverseGaussJordan();
|
||||||
default:
|
default:
|
||||||
|
|
@ -201,10 +201,10 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
$newMatrixArr = $this->matrix;
|
$newMatrixArr = $this->matrix;
|
||||||
|
|
||||||
// extending matrix by identity matrix
|
// extending matrix by identity matrix
|
||||||
for($i = 0; $i < $this->n; $i++) {
|
for ($i = 0; $i < $this->n; $i++) {
|
||||||
for($j = $this->n; $j < $this->n * 2; $j++) {
|
for ($j = $this->n; $j < $this->n * 2; $j++) {
|
||||||
|
|
||||||
if($j === ($i + $this->n)) {
|
if ($j === ($i + $this->n)) {
|
||||||
$newMatrixArr[$i][$j] = 1;
|
$newMatrixArr[$i][$j] = 1;
|
||||||
} else {
|
} else {
|
||||||
$newMatrixArr[$i][$j] = 0;
|
$newMatrixArr[$i][$j] = 0;
|
||||||
|
|
@ -219,16 +219,16 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
$newMatrixArr = $this->diag($newMatrixArr);
|
$newMatrixArr = $this->diag($newMatrixArr);
|
||||||
|
|
||||||
/* create unit matrix */
|
/* create unit matrix */
|
||||||
for($i = 0; $i < $mDim; $i++) {
|
for ($i = 0; $i < $mDim; $i++) {
|
||||||
$temp = $newMatrixArr[$i][$i];
|
$temp = $newMatrixArr[$i][$i];
|
||||||
|
|
||||||
for($j = 0; $j < $nDim; $j++) {
|
for ($j = 0; $j < $nDim; $j++) {
|
||||||
$newMatrixArr[$i][$j] = $newMatrixArr[$i][$j] / $temp;
|
$newMatrixArr[$i][$j] = $newMatrixArr[$i][$j] / $temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* removing identity matrix */
|
/* removing identity matrix */
|
||||||
for($i = 0; $i < $mDim; $i++) {
|
for ($i = 0; $i < $mDim; $i++) {
|
||||||
$newMatrixArr[$i] = array_slice($newMatrixArr[$i], $mDim);
|
$newMatrixArr[$i] = array_slice($newMatrixArr[$i], $mDim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -244,7 +244,7 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
$newMatrixArr = $newMatrix->getMatrix();
|
$newMatrixArr = $newMatrix->getMatrix();
|
||||||
|
|
||||||
for ($i = 0; $i < $this->n; $i++) {
|
for ($i = 0; $i < $this->n; $i++) {
|
||||||
for ($j = 0; $j < $i+1; $j++) {
|
for ($j = 0; $j < $i + 1; $j++) {
|
||||||
$temp = 0;
|
$temp = 0;
|
||||||
|
|
||||||
for ($c = 0; $c < $j; $c++) {
|
for ($c = 0; $c < $j; $c++) {
|
||||||
|
|
@ -265,23 +265,23 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
$mDim = count($arr);
|
$mDim = count($arr);
|
||||||
$nDim = count($arr[0]);
|
$nDim = count($arr[0]);
|
||||||
|
|
||||||
for($i = $mDim - 1; $i > 0; $i--) {
|
for ($i = $mDim - 1; $i > 0; $i--) {
|
||||||
if ($arr[$i - 1][0] < $arr[$i][0]) {
|
if ($arr[$i - 1][0] < $arr[$i][0]) {
|
||||||
for($j = 0; $j < $nDim; $j++) {
|
for ($j = 0; $j < $nDim; $j++) {
|
||||||
$temp = $arr[$i][$j];
|
$temp = $arr[$i][$j];
|
||||||
$arr[$i][$j] = $arr[$i-1][$j];
|
$arr[$i][$j] = $arr[$i - 1][$j];
|
||||||
$arr[$i-1][$j] = $temp;
|
$arr[$i - 1][$j] = $temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create diagonal matrix */
|
/* create diagonal matrix */
|
||||||
for($i = 0; $i < $mDim; $i++) {
|
for ($i = 0; $i < $mDim; $i++) {
|
||||||
for($j = 0; $j < $mDim; $j++) {
|
for ($j = 0; $j < $mDim; $j++) {
|
||||||
if ($j !== $i) {
|
if ($j !== $i) {
|
||||||
$temp = $arr[$j][$i] / $arr[$i][$i];
|
$temp = $arr[$j][$i] / $arr[$i][$i];
|
||||||
|
|
||||||
for($c = 0; $c < $nDim; $c++) {
|
for ($c = 0; $c < $nDim; $c++) {
|
||||||
$arr[$j][$c] -= $arr[$i][$c] * $temp;
|
$arr[$j][$c] -= $arr[$i][$c] * $temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +323,7 @@ class Matrix implements ArrayAccess, Iterator
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($c = $i; $c < $n; $c ++) {
|
for ($c = $i; $c < $n; $c++) {
|
||||||
$arr[$j][$c] -= $arr[$i][$c] * $r;
|
$arr[$j][$c] -= $arr[$i][$c] * $r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,17 +94,23 @@ class Numbers
|
||||||
|
|
||||||
// This tests if the 6 least significant bits are right.
|
// This tests if the 6 least significant bits are right.
|
||||||
// Moving the to be tested bit to the highest position saves us masking.
|
// Moving the to be tested bit to the highest position saves us masking.
|
||||||
if ($goodMask << $n >= 0) return false;
|
if ($goodMask << $n >= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$numberOfTrailingZeros = self::countTrailingZeros($n);
|
$numberOfTrailingZeros = self::countTrailingZeros($n);
|
||||||
// Each square ends with an even number of zeros.
|
// Each square ends with an even number of zeros.
|
||||||
if (($numberOfTrailingZeros & 1) !== 0) return false;
|
if (($numberOfTrailingZeros & 1) !== 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$n >>= $numberOfTrailingZeros;
|
$n >>= $numberOfTrailingZeros;
|
||||||
// Now x is either 0 or odd.
|
// Now x is either 0 or odd.
|
||||||
// In binary each odd square ends with 001.
|
// In binary each odd square ends with 001.
|
||||||
// Postpone the sign test until now; handle zero in the branch.
|
// Postpone the sign test until now; handle zero in the branch.
|
||||||
if (($n&7) != 1 | $n <= 0) return $n === 0;
|
if (($n&7) != 1 | $n <= 0) {
|
||||||
|
return $n === 0;
|
||||||
|
}
|
||||||
// Do it in the classical way.
|
// Do it in the classical way.
|
||||||
// The correctness is not trivial as the conversion from long to double is lossy!
|
// The correctness is not trivial as the conversion from long to double is lossy!
|
||||||
$tst = (int) sqrt($n);
|
$tst = (int) sqrt($n);
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class Prime
|
||||||
*/
|
*/
|
||||||
public static function isMersenne(int $n) : bool
|
public static function isMersenne(int $n) : bool
|
||||||
{
|
{
|
||||||
$mersenne = log($n+1, 2);
|
$mersenne = log($n + 1, 2);
|
||||||
|
|
||||||
return $mersenne - (int) $mersenne < 0.00001;
|
return $mersenne - (int) $mersenne < 0.00001;
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +78,7 @@ class Prime
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($n < 2 || $n % 2 == 0){
|
if ($n < 2 || $n % 2 == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,11 +91,11 @@ class Prime
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < $k; $i++) {
|
for ($i = 0; $i < $k; $i++) {
|
||||||
$a = mt_rand(2, $n-1);
|
$a = mt_rand(2, $n - 1);
|
||||||
|
|
||||||
$x = bcpowmod($a, $d, $n);
|
$x = bcpowmod($a, $d, $n);
|
||||||
|
|
||||||
if ($x == 1 || $x == $n-1) {
|
if ($x == 1 || $x == $n - 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ class Prime
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($x == $n-1) {
|
if ($x == $n - 1) {
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@ class GaussianElimination
|
||||||
{
|
{
|
||||||
private function swapRows(&$a, &$b, $r1, $r2)
|
private function swapRows(&$a, &$b, $r1, $r2)
|
||||||
{
|
{
|
||||||
if ($r1 == $r2) return;
|
if ($r1 == $r2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$tmp = $a[$r1];
|
$tmp = $a[$r1];
|
||||||
$a[$r1] = $a[$r2];
|
$a[$r1] = $a[$r2];
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ class Graph
|
||||||
*/
|
*/
|
||||||
public function addVertice(VerticeInterface $vertice) : bool
|
public function addVertice(VerticeInterface $vertice) : bool
|
||||||
{
|
{
|
||||||
if(!isset($this->vertices[$vertice->getId()])) {
|
if (!isset($this->vertices[$vertice->getId()])) {
|
||||||
$this->vertices[$vertice->getId()] = $vertice;
|
$this->vertices[$vertice->getId()] = $vertice;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -88,7 +88,7 @@ class Graph
|
||||||
*/
|
*/
|
||||||
public function addEdge(EdgeInterface $edge) : bool
|
public function addEdge(EdgeInterface $edge) : bool
|
||||||
{
|
{
|
||||||
if(!isset($this->edges[$edge->getId()])) {
|
if (!isset($this->edges[$edge->getId()])) {
|
||||||
$this->edges[$edge->getId()] = $edge;
|
$this->edges[$edge->getId()] = $edge;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -109,7 +109,7 @@ class Graph
|
||||||
*/
|
*/
|
||||||
public function removeVertice($id) : bool
|
public function removeVertice($id) : bool
|
||||||
{
|
{
|
||||||
if(isset($this->vertices[$id])) {
|
if (isset($this->vertices[$id])) {
|
||||||
unset($this->vertices[$id]);
|
unset($this->vertices[$id]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -146,7 +146,7 @@ class Graph
|
||||||
*/
|
*/
|
||||||
public function removeEdgeById($id) : bool
|
public function removeEdgeById($id) : bool
|
||||||
{
|
{
|
||||||
if(isset($this->edge[$id])) {
|
if (isset($this->edge[$id])) {
|
||||||
unset($this->edge[$id]);
|
unset($this->edge[$id]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,9 @@ class Average
|
||||||
$avgcos = $coss / (0.0 + count($angles));
|
$avgcos = $coss / (0.0 + count($angles));
|
||||||
$avgang = rad2deg(atan2($avgsin, $avgcos));
|
$avgang = rad2deg(atan2($avgsin, $avgcos));
|
||||||
|
|
||||||
while ($avgang < 0.0) $avgang += 360.0;
|
while ($avgang < 0.0) {
|
||||||
|
$avgang += 360.0;
|
||||||
|
}
|
||||||
|
|
||||||
return $avgang;
|
return $avgang;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ class Response extends ResponseAbstract implements RenderableInterface
|
||||||
*/
|
*/
|
||||||
public function pushHeaderId($name)
|
public function pushHeaderId($name)
|
||||||
{
|
{
|
||||||
if(self::$isLocked) {
|
if (self::$isLocked) {
|
||||||
throw new \Exception('Already locked');
|
throw new \Exception('Already locked');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,7 +102,7 @@ class Response extends ResponseAbstract implements RenderableInterface
|
||||||
*/
|
*/
|
||||||
public function removeHeader(int $key) : bool
|
public function removeHeader(int $key) : bool
|
||||||
{
|
{
|
||||||
if(self::$isLocked) {
|
if (self::$isLocked) {
|
||||||
throw new \Exception('Already locked');
|
throw new \Exception('Already locked');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,7 +212,7 @@ class Response extends ResponseAbstract implements RenderableInterface
|
||||||
*/
|
*/
|
||||||
public function pushHeader()
|
public function pushHeader()
|
||||||
{
|
{
|
||||||
if(self::$isLocked) {
|
if (self::$isLocked) {
|
||||||
throw new \Exception('Already locked');
|
throw new \Exception('Already locked');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,7 +237,7 @@ class Response extends ResponseAbstract implements RenderableInterface
|
||||||
*/
|
*/
|
||||||
public function remove(int $id) : bool
|
public function remove(int $id) : bool
|
||||||
{
|
{
|
||||||
if(self::$isLocked) {
|
if (self::$isLocked) {
|
||||||
throw new \Exception('Already locked');
|
throw new \Exception('Already locked');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -374,7 +374,7 @@ class Response extends ResponseAbstract implements RenderableInterface
|
||||||
*/
|
*/
|
||||||
public function setHeader($key, string $header, bool $overwrite = false) : bool
|
public function setHeader($key, string $header, bool $overwrite = false) : bool
|
||||||
{
|
{
|
||||||
if(self::$isLocked) {
|
if (self::$isLocked) {
|
||||||
throw new \Exception('Already locked');
|
throw new \Exception('Already locked');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class Imap extends Mail
|
||||||
|
|
||||||
public function getInbox(string $option = 'ALL') : array
|
public function getInbox(string $option = 'ALL') : array
|
||||||
{
|
{
|
||||||
$ids = imap_search($this->inbox, $option, SE_FREE, 'UTF-8');
|
$ids = imap_search($this->inbox, $option, SE_FREE, 'UTF-8');
|
||||||
|
|
||||||
return is_array($ids) ? imap_fetch_overview($this->inbox, implode(',', $ids)) : [];
|
return is_array($ids) ? imap_fetch_overview($this->inbox, implode(',', $ids)) : [];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
*/
|
*/
|
||||||
public function setRequestSource($source)
|
public function setRequestSource($source)
|
||||||
{
|
{
|
||||||
if(!RequestSource::isValidValue($source)) {
|
if (!RequestSource::isValidValue($source)) {
|
||||||
throw new InvalidEnumValue($source);
|
throw new InvalidEnumValue($source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class ModuleFactory
|
||||||
self::$loaded[$module] = $obj;
|
self::$loaded[$module] = $obj;
|
||||||
self::registerRequesting($obj);
|
self::registerRequesting($obj);
|
||||||
self::registerProvided($obj);
|
self::registerProvided($obj);
|
||||||
} catch(\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
self::$loaded[$module] = new NullModule($app);
|
self::$loaded[$module] = new NullModule($app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,7 @@ class ModuleManager
|
||||||
|
|
||||||
$path = realpath($oldPath = self::MODULE_PATH . '/' . $module . '/' . 'info.json');
|
$path = realpath($oldPath = self::MODULE_PATH . '/' . $module . '/' . 'info.json');
|
||||||
|
|
||||||
if($path === false || strpos($path, self::MODULE_PATH) === false) {
|
if ($path === false || strpos($path, self::MODULE_PATH) === false) {
|
||||||
throw new PathException($module);
|
throw new PathException($module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
|
||||||
$this->filter = $filter;
|
$this->filter = $filter;
|
||||||
parent::__construct($path);
|
parent::__construct($path);
|
||||||
|
|
||||||
if(file_exists($this->path)) {
|
if (file_exists($this->path)) {
|
||||||
parent::index();
|
parent::index();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -242,7 +242,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
|
||||||
*/
|
*/
|
||||||
public function remove(string $name) : bool
|
public function remove(string $name) : bool
|
||||||
{
|
{
|
||||||
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();
|
||||||
|
|
||||||
|
|
@ -269,7 +269,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
|
||||||
|
|
||||||
foreach (glob($this->path . DIRECTORY_SEPARATOR . $this->filter) as $filename) {
|
foreach (glob($this->path . DIRECTORY_SEPARATOR . $this->filter) as $filename) {
|
||||||
// todo: handle . and ..???!!!
|
// todo: handle . and ..???!!!
|
||||||
if(is_dir($filename)) {
|
if (is_dir($filename)) {
|
||||||
$file = new Directory($filename);
|
$file = new Directory($filename);
|
||||||
$file->index();
|
$file->index();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -349,7 +349,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
|
||||||
*/
|
*/
|
||||||
public function offsetUnset($offset)
|
public function offsetUnset($offset)
|
||||||
{
|
{
|
||||||
if(isset($this->nodes[$offset])) {
|
if (isset($this->nodes[$offset])) {
|
||||||
unset($this->nodes[$offset]);
|
unset($this->nodes[$offset]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class File extends FileAbstract
|
||||||
public static function createFile(string $path) : bool
|
public static function createFile(string $path) : bool
|
||||||
{
|
{
|
||||||
if (!file_exists($path)) {
|
if (!file_exists($path)) {
|
||||||
if(is_writable(Directory::getParent($path))) {
|
if (is_writable(Directory::getParent($path))) {
|
||||||
touch($path);
|
touch($path);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -69,7 +69,7 @@ class File extends FileAbstract
|
||||||
parent::__construct($path);
|
parent::__construct($path);
|
||||||
$this->count = 1;
|
$this->count = 1;
|
||||||
|
|
||||||
if(file_exists($this->path)) {
|
if (file_exists($this->path)) {
|
||||||
$this->index();
|
$this->index();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ final class OperatingSystem {
|
||||||
*/
|
*/
|
||||||
public static function getSystem() : int
|
public static function getSystem() : int
|
||||||
{
|
{
|
||||||
switch(PHP_OS) {
|
switch (PHP_OS) {
|
||||||
case stristr(PHP_OS, 'DAR'):
|
case stristr(PHP_OS, 'DAR'):
|
||||||
return SystemType::OSX;
|
return SystemType::OSX;
|
||||||
case stristr(PHP_OS, 'WIN'):
|
case stristr(PHP_OS, 'WIN'):
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,7 @@ class Http implements UriInterface
|
||||||
$this->pass = $url['pass'] ?? null;
|
$this->pass = $url['pass'] ?? null;
|
||||||
$this->path = $url['path'] ?? null;
|
$this->path = $url['path'] ?? null;
|
||||||
$this->path = rtrim($this->path, '.php');
|
$this->path = rtrim($this->path, '.php');
|
||||||
$this->path = strpos($this->path, $this->rootPath) === 0 ? substr($this->path, strlen($this->rootPath), strlen($this->path)) : $this->path; // TODO: this could cause a bug if the rootpath is the same as a regular path which is usually the language
|
$this->path = strpos($this->path, $this->rootPath) === 0 ? substr($this->path, strlen($this->rootPath), strlen($this->path)) : $this->path; // TODO: this could cause a bug if the rootpath is the same as a regular path which is usually the language
|
||||||
$this->query = $url['query'] ?? null;
|
$this->query = $url['query'] ?? null;
|
||||||
|
|
||||||
if (isset($this->query)) {
|
if (isset($this->query)) {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ abstract class C128Abstract
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static $CODE_END = '';
|
protected static $CODE_END = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Orientation.
|
* Orientation.
|
||||||
|
|
@ -76,7 +76,7 @@ abstract class C128Abstract
|
||||||
* @var int
|
* @var int
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $size = 0;
|
protected $size = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Barcode dimension.
|
* Barcode dimension.
|
||||||
|
|
@ -86,7 +86,7 @@ abstract class C128Abstract
|
||||||
* @var int[]
|
* @var int[]
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $dimension = ['width' => 0, 'height' => 0];
|
protected $dimension = ['width' => 0, 'height' => 0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content to encrypt.
|
* Content to encrypt.
|
||||||
|
|
@ -94,7 +94,7 @@ abstract class C128Abstract
|
||||||
* @var string|int
|
* @var string|int
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $content = 0;
|
protected $content = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show text below barcode.
|
* Show text below barcode.
|
||||||
|
|
@ -102,7 +102,7 @@ abstract class C128Abstract
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $showText = true;
|
protected $showText = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Margin for barcode (padding).
|
* Margin for barcode (padding).
|
||||||
|
|
@ -110,7 +110,7 @@ abstract class C128Abstract
|
||||||
* @var int[]
|
* @var int[]
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $margin = ['top' => 0, 'right' => 4, 'bottom' => 0, 'left' => 4];
|
protected $margin = ['top' => 0, 'right' => 4, 'bottom' => 0, 'left' => 4];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Background color.
|
* Background color.
|
||||||
|
|
@ -118,7 +118,7 @@ abstract class C128Abstract
|
||||||
* @var int[]
|
* @var int[]
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $background = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0];
|
protected $background = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Front color.
|
* Front color.
|
||||||
|
|
@ -126,7 +126,7 @@ abstract class C128Abstract
|
||||||
* @var int[]
|
* @var int[]
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $front = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0];
|
protected $front = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class C25 extends C128Abstract
|
||||||
*/
|
*/
|
||||||
public function __construct(string $content = '', int $size = 20, int $orientation = OrientationType::HORIZONTAL)
|
public function __construct(string $content = '', int $size = 20, int $orientation = OrientationType::HORIZONTAL)
|
||||||
{
|
{
|
||||||
if(!ctype_digit($content)) {
|
if (!ctype_digit($content)) {
|
||||||
throw new \InvalidArgumentException($content);
|
throw new \InvalidArgumentException($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,7 +95,7 @@ class C25 extends C128Abstract
|
||||||
*/
|
*/
|
||||||
public function setContent(string $content)
|
public function setContent(string $content)
|
||||||
{
|
{
|
||||||
if(!ctype_digit($content)) {
|
if (!ctype_digit($content)) {
|
||||||
throw new \InvalidArgumentException($content);
|
throw new \InvalidArgumentException($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ final class Gray {
|
||||||
{
|
{
|
||||||
$source = $gray;
|
$source = $gray;
|
||||||
|
|
||||||
while($gray >>= 1) {
|
while ($gray >>= 1) {
|
||||||
$source ^= $gray;
|
$source ^= $gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ class Commit
|
||||||
$branch = new Branch();
|
$branch = new Branch();
|
||||||
$tag = new Tag();
|
$tag = new Tag();
|
||||||
|
|
||||||
if(!empty($id)) {
|
if (!empty($id)) {
|
||||||
// todo: fill base info
|
// todo: fill base info
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +119,7 @@ class Commit
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function addFile(string $path) {
|
public function addFile(string $path) {
|
||||||
if(!isset($this->files[$path])) {
|
if (!isset($this->files[$path])) {
|
||||||
$this->files[$path] = [];
|
$this->files[$path] = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +203,7 @@ class Commit
|
||||||
*/
|
*/
|
||||||
public function removeFile(string $path) : bool
|
public function removeFile(string $path) : bool
|
||||||
{
|
{
|
||||||
if(isset($this->files[$path])) {
|
if (isset($this->files[$path])) {
|
||||||
unset($this->files[$path]);
|
unset($this->files[$path]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class Git {
|
||||||
$stdout = stream_get_contents($pipes[1]);
|
$stdout = stream_get_contents($pipes[1]);
|
||||||
$stderr = stream_get_contents($pipes[2]);
|
$stderr = stream_get_contents($pipes[2]);
|
||||||
|
|
||||||
foreach($pipes as $pipe) {
|
foreach ($pipes as $pipe) {
|
||||||
fclose($pipe);
|
fclose($pipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class Repository
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $path = '';
|
private $path = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bare repository.
|
* Bare repository.
|
||||||
|
|
@ -42,7 +42,7 @@ class Repository
|
||||||
* @var bool
|
* @var bool
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $bare = false;
|
private $bare = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Env variables.
|
* Env variables.
|
||||||
|
|
|
||||||
|
|
@ -31,5 +31,5 @@ use phpOMS\Datatypes\Enum;
|
||||||
abstract class OrderType extends Enum
|
abstract class OrderType extends Enum
|
||||||
{
|
{
|
||||||
const LOOSE = 0;
|
const LOOSE = 0;
|
||||||
const STRICT= 1;
|
const STRICT = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -584,14 +584,18 @@ class Markdown
|
||||||
if (isset($block['closed'])) {
|
if (isset($block['closed'])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (preg_match('/^<' . $block['name'] . '(?:[ ]*' . $this->regexHtmlAttribute . ')*[ ]*>/i', $line['text'])) # open
|
if (preg_match('/^<' . $block['name'] . '(?:[ ]*' . $this->regexHtmlAttribute . ')*[ ]*>/i', $line['text'])) {
|
||||||
|
# open
|
||||||
{
|
{
|
||||||
$block['depth']++;
|
$block['depth']++;
|
||||||
}
|
}
|
||||||
if (preg_match('/(.*?)<\/' . $block['name'] . '>[ ]*$/i', $line['text'], $matches)) # close
|
}
|
||||||
|
if (preg_match('/(.*?)<\/' . $block['name'] . '>[ ]*$/i', $line['text'], $matches)) {
|
||||||
|
# close
|
||||||
{
|
{
|
||||||
if ($block['depth'] > 0) {
|
if ($block['depth'] > 0) {
|
||||||
$block['depth']--;
|
$block['depth']--;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$block['closed'] = true;
|
$block['closed'] = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class Permutation
|
||||||
|
|
||||||
if(empty($toPermute)){
|
if(empty($toPermute)){
|
||||||
$permutations[] = implode('', $result);
|
$permutations[] = implode('', $result);
|
||||||
}else{
|
} else{
|
||||||
foreach($toPermute as $key => $val){
|
foreach($toPermute as $key => $val){
|
||||||
$newArr = $toPermute;
|
$newArr = $toPermute;
|
||||||
$newres = $result;
|
$newres = $result;
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ class Text
|
||||||
*/
|
*/
|
||||||
public function generateText($length, $words = null)
|
public function generateText($length, $words = null)
|
||||||
{
|
{
|
||||||
if($length === 0) {
|
if ($length === 0) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class SystemUtils
|
||||||
$countSize = 0;
|
$countSize = 0;
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
if(is_readable($dir)) {
|
if (is_readable($dir)) {
|
||||||
$dir_array = scandir($dir);
|
$dir_array = scandir($dir);
|
||||||
|
|
||||||
foreach ($dir_array as $key => $filename) {
|
foreach ($dir_array as $key => $filename) {
|
||||||
|
|
|
||||||
|
|
@ -491,10 +491,14 @@ class Interval
|
||||||
private function validateMinute(array $array) : bool
|
private function validateMinute(array $array) : bool
|
||||||
{
|
{
|
||||||
foreach ($array['minutes'] as $minute) {
|
foreach ($array['minutes'] as $minute) {
|
||||||
if ($minute > 59 || $minute < 0) return false;
|
if ($minute > 59 || $minute < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($array['step'] > 59 || $array['step'] < 0) return false;
|
if ($array['step'] > 59 || $array['step'] < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -512,10 +516,14 @@ class Interval
|
||||||
private function validateHour(array $array) : bool
|
private function validateHour(array $array) : bool
|
||||||
{
|
{
|
||||||
foreach ($array['hours'] as $hour) {
|
foreach ($array['hours'] as $hour) {
|
||||||
if ($hour > 23 || $hour < 0) return false;
|
if ($hour > 23 || $hour < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($array['step'] > 23 || $array['step'] < 0) return false;
|
if ($array['step'] > 23 || $array['step'] < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -533,11 +541,17 @@ class Interval
|
||||||
private function validateDayOfMonth(array $array) : bool
|
private function validateDayOfMonth(array $array) : bool
|
||||||
{
|
{
|
||||||
foreach ($array['dayOfMonth'] as $dayOfMonth) {
|
foreach ($array['dayOfMonth'] as $dayOfMonth) {
|
||||||
if ($dayOfMonth > 31 || $dayOfMonth < 1) return false;
|
if ($dayOfMonth > 31 || $dayOfMonth < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($array['step'] > 31 || $array['step'] < 1) return false;
|
if ($array['step'] > 31 || $array['step'] < 1) {
|
||||||
if ($array['nearest'] > 31 || $array['nearest'] < 1) return false;
|
return false;
|
||||||
|
}
|
||||||
|
if ($array['nearest'] > 31 || $array['nearest'] < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -555,10 +569,14 @@ class Interval
|
||||||
private function validateMonth(array $array) : bool
|
private function validateMonth(array $array) : bool
|
||||||
{
|
{
|
||||||
foreach ($array['month'] as $month) {
|
foreach ($array['month'] as $month) {
|
||||||
if ($month > 12 || $month < 1) return false;
|
if ($month > 12 || $month < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($array['step'] > 12 || $array['step'] < 1) return false;
|
if ($array['step'] > 12 || $array['step'] < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -576,10 +594,14 @@ class Interval
|
||||||
private function validateDayOfWeek(array $array) : bool
|
private function validateDayOfWeek(array $array) : bool
|
||||||
{
|
{
|
||||||
foreach ($array['dayOfWeek'] as $dayOfWeek) {
|
foreach ($array['dayOfWeek'] as $dayOfWeek) {
|
||||||
if ($dayOfWeek > 7 || $dayOfWeek < 1) return false;
|
if ($dayOfWeek > 7 || $dayOfWeek < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($array['step'] > 5 || $array['step'] < 1) return false;
|
if ($array['step'] > 5 || $array['step'] < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ abstract class CreditCard extends ValidatorAbstract
|
||||||
public static function luhnTest(string $num) {
|
public static function luhnTest(string $num) {
|
||||||
$len = strlen($num);
|
$len = strlen($num);
|
||||||
|
|
||||||
for ($i = $len-1; $i >= 0; $i--) {
|
for ($i = $len - 1; $i >= 0; $i--) {
|
||||||
$ord = ord($num[$i]);
|
$ord = ord($num[$i]);
|
||||||
|
|
||||||
if (($len - 1) & $i) {
|
if (($len - 1) & $i) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user