Formatting & bug fixes

This commit is contained in:
Dennis Eichhorn 2016-05-05 11:27:16 +02:00
parent 292ac8d739
commit ce182bab92
166 changed files with 2560 additions and 3372 deletions

View File

@ -422,7 +422,8 @@ class Account
$this->lastActive = new \DateTime('NOW');
}
public function setCreatedAt(\DateTime $created) {
public function setCreatedAt(\DateTime $created)
{
$this->createdAt = $created;
}

View File

@ -112,7 +112,8 @@ class AccountManager implements \Countable
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function count() : int {
public function count() : int
{
return count($this->accounts);
}

View File

@ -124,6 +124,7 @@ class MemCache implements CacheInterface
*/
public function stats() : array
{
/** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
return $this->memc->getExtendedStats();
}

View File

@ -15,6 +15,7 @@
*/
namespace phpOMS\DataStorage\Database;
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
/**

View File

@ -262,7 +262,8 @@ abstract class DataMapperAbstract implements DataMapperInterface
return $this;
}
public function clear() {
public function clear()
{
$this->fields = [];
}
@ -361,7 +362,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
$value = isset($value) ? json_encode($value) : '';
} elseif ($column['type'] === 'Serializable') {
$value = $value->serialize();
} elseif(is_object($value)) {
} elseif (is_object($value)) {
$value = $value->getId();
}
@ -1005,15 +1006,15 @@ abstract class DataMapperAbstract implements DataMapperInterface
->where($value['table'] . '.' . $value['dst'], '=', $primaryKey);
} elseif ($relations === RelationType::NEWEST) {
/*
SELECT c.*, p1.*
FROM customer c
JOIN purchase p1 ON (c.id = p1.customer_id)
LEFT OUTER JOIN purchase p2 ON (c.id = p2.customer_id AND
/*
SELECT c.*, p1.*
FROM customer c
JOIN purchase p1 ON (c.id = p1.customer_id)
LEFT OUTER JOIN purchase p2 ON (c.id = p2.customer_id AND
(p1.date < p2.date OR p1.date = p2.date AND p1.id < p2.id))
WHERE p2.id IS NULL;
*/
/*
WHERE p2.id IS NULL;
*/
/*
$query->select(static::$table . '.' . static::$primaryField, $value['table'] . '.' . $value['src'])
->from(static::$table)
->join($value['table'])

View File

@ -42,7 +42,7 @@ class DatabaseExceptionFactory
*/
public static function create(\PDOException $e) : \PDOException
{
switch($e->getCode()) {
switch ($e->getCode()) {
case '42S02':
return self::createTableViewException($e);
default:

View File

@ -89,7 +89,7 @@ abstract class GrammarAbstract
implode(' ',
array_filter(
$this->compileComponents($query),
function($value) {
function ($value) {
return (string) $value !== '';
}
)

View File

@ -47,16 +47,16 @@ class TableException extends \PDOException
{
$pos1 = strpos($message, '\'');
if($pos1 === false) {
if ($pos1 === false) {
return $message;
}
$pos2 = strpos($message, '\'', $pos1+1);
$pos2 = strpos($message, '\'', $pos1 + 1);
if($pos2 === false) {
if ($pos2 === false) {
return $message;
}
return substr($message, $pos1+1, $pos2-$pos1-1);
return substr($message, $pos1 + 1, $pos2 - $pos1 - 1);
}
}

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com
*/
namespace phpOMS\DataStorage\Session;
use phpOMS\Uri\UriFactory;
use phpOMS\Utils\RnG\StringUtils;

View File

@ -262,12 +262,12 @@ class FileLogger implements LoggerInterface
* @param array $a
* @param array $b
*
* @return bool the comparison
* @return int
*
* @since 1.0.0
* @author Dennis Eichhorn
*/
private function orderSort($a, $b)
private function orderSort($a, $b) : int
{
if ($a['time'] == $b['time']) {
return 0;
@ -297,7 +297,7 @@ class FileLogger implements LoggerInterface
}
if (self::$verbose) {
echo $message , "\n";
echo $message, "\n";
}
}

View File

@ -31,7 +31,7 @@ class Fibunacci
{
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
@ -57,6 +57,6 @@ class Fibunacci
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)));
}
}

View File

@ -149,7 +149,8 @@ class Functions
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function invMod($a, $n) {
public static function invMod($a, $n)
{
if ($n < 0) {
$n = -$n;
}

View File

@ -2,13 +2,14 @@
namespace phpOMS\Math\Matrix;
class IdentityMatrix extends Matrix {
class IdentityMatrix extends Matrix
{
public function __constrcut(int $n)
{
$this->n = $n;
$this->m = $n;
for($i = 0; $i < $n; $i++) {
for ($i = 0; $i < $n; $i++) {
$this->matrix[$i] = array_fill(0, $n, 0);
$this->matrix[$i][$i] = 1;
}

View File

@ -172,7 +172,9 @@ class Matrix implements \ArrayAccess, \Iterator
$matrix = new Matrix($this->n, $this->n);
$matrixArr = $this->matrix;
$matrix->setMatrix($this->upperTrianglize($matrixArr));
$this->upperTrianglize($matrixArr);
$matrix->setMatrix($matrixArr);
return $matrix;
}
@ -348,4 +350,122 @@ class Matrix implements \ArrayAccess, \Iterator
return $prod;
}
/**
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
* @return mixed Can return any type.
* @since 5.0.0
*/
public function current()
{
// TODO: Implement current() method.
}
/**
* Move forward to next element
* @link http://php.net/manual/en/iterator.next.php
* @return void Any returned value is ignored.
* @since 5.0.0
*/
public function next()
{
// TODO: Implement next() method.
}
/**
* Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
* @since 5.0.0
*/
public function key()
{
// TODO: Implement key() method.
}
/**
* Checks if current position is valid
* @link http://php.net/manual/en/iterator.valid.php
* @return boolean The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
* @since 5.0.0
*/
public function valid()
{
// TODO: Implement valid() method.
}
/**
* Rewind the Iterator to the first element
* @link http://php.net/manual/en/iterator.rewind.php
* @return void Any returned value is ignored.
* @since 5.0.0
*/
public function rewind()
{
// TODO: Implement rewind() method.
}
/**
* Whether a offset exists
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
* @param mixed $offset <p>
* An offset to check for.
* </p>
* @return boolean true on success or false on failure.
* </p>
* <p>
* The return value will be casted to boolean if non-boolean was returned.
* @since 5.0.0
*/
public function offsetExists($offset)
{
// TODO: Implement offsetExists() method.
}
/**
* Offset to retrieve
* @link http://php.net/manual/en/arrayaccess.offsetget.php
* @param mixed $offset <p>
* The offset to retrieve.
* </p>
* @return mixed Can return all value types.
* @since 5.0.0
*/
public function offsetGet($offset)
{
// TODO: Implement offsetGet() method.
}
/**
* Offset to set
* @link http://php.net/manual/en/arrayaccess.offsetset.php
* @param mixed $offset <p>
* The offset to assign the value to.
* </p>
* @param mixed $value <p>
* The value to set.
* </p>
* @return void
* @since 5.0.0
*/
public function offsetSet($offset, $value)
{
// TODO: Implement offsetSet() method.
}
/**
* Offset to unset
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
* @param mixed $offset <p>
* The offset to unset.
* </p>
* @return void
* @since 5.0.0
*/
public function offsetUnset($offset)
{
// TODO: Implement offsetUnset() method.
}
}

View File

@ -2,7 +2,8 @@
namespace phpOMS\Math\Matrix;
class Vector extends Matrix {
class Vector extends Matrix
{
public function __construct(int $m)
{
parent::__construct($m);

View File

@ -1,7 +1,7 @@
<?php
use phpOMS\Math\Number\Prime;
class Integer implements Number
class Integer
{
public static function isInteger($value) : bool
{
@ -24,7 +24,8 @@ class Integer implements Number
while (true) {
if ($n === $m) {
return $m;
} if ($n > $m) {
}
if ($n > $m) {
$n -= $m;
} else {
$m -= $n;
@ -41,20 +42,20 @@ class Integer implements Number
}
$factors = [];
$primes = Prime::sieveOfEratosthenes((int) $value**0.5);
$primes = Prime::sieveOfEratosthenes((int) $value ** 0.5);
foreach($primes as $prime) {
if($prime*$prime > $value) {
foreach ($primes as $prime) {
if ($prime * $prime > $value) {
break;
}
while($value%$prime === 0) {
while ($value % $prime === 0) {
$factors[] = $prime;
$value /= $prime;
}
}
if($value > 1) {
if ($value > 1) {
$factors[] = $value;
}
@ -63,10 +64,10 @@ class Integer implements Number
public static function pollardsRho($value, $x = 2, $factor = 1, $cycleSize = 2, $xFixed = 2)
{
while($factor === 1) {
for($i = 1; $i < $cycleSize && $factor <= 1; $i++) {
$x = ($x*$x+1)%$value;
$factor = self::greatestCommonDivisor($x-$xFixed, $value);
while ($factor === 1) {
for ($i = 1; $i < $cycleSize && $factor <= 1; $i++) {
$x = ($x * $x + 1) % $value;
$factor = self::greatestCommonDivisor($x - $xFixed, $value);
}
$cycleSize *= 2;
@ -79,11 +80,11 @@ class Integer implements Number
public static function fermatFactor(int $value)
{
$a = $value;
$b2 = $a*$a - $value;
$b2 = $a * $a - $value;
while(abs((int) round(sqrt($b2), 0) - sqrt($b2)) > 0.0001) {
while (abs((int) round(sqrt($b2), 0) - sqrt($b2)) > 0.0001) {
$a += 1;
$b2 = $a*$a - $value;
$b2 = $a * $a - $value;
}
return $a - sqrt($b2);

View File

@ -1,6 +1,6 @@
<?php
class Natural implements Number
class Natural
{
public static function isNatural($value) : bool
{

View File

@ -1,5 +1,9 @@
class Number {
public static function getType($number) {
<?php
}
class Number
{
public static function getType($number)
{
}
}

View File

@ -1,8 +0,0 @@
interface NumberInterface {
public function add($number);
public function sub($number);
public function mult($number);
public function div($number);
public function pow($p);
public function abs($number);
}

View File

@ -0,0 +1,16 @@
<?php
interface NumberInterface
{
public function add($number);
public function sub($number);
public function mult($number);
public function div($number);
public function pow($p);
public function abs($number);
}

View File

@ -58,7 +58,7 @@ class Prime
*/
public static function mersenne(int $p) : int
{
return 2**$p - 1;
return 2 ** $p - 1;
}
/**
@ -123,7 +123,7 @@ class Prime
$range = range(2, $n);
$primes = array_combine($range, $range);
while ($number*$number < $n) {
while ($number * $number < $n) {
for ($i = $number; $i <= $n; $i += $number) {
if ($i == $number) {
continue;

View File

@ -2,8 +2,10 @@
namespace phpOMS\Math\Optimization\Graph;
class Dijkstra {
public static function dijkstra(Graph $graph, $source, $target) {
class Dijkstra
{
public static function dijkstra(Graph $graph, $source, $target)
{
$vertices = [];
$neighbours = [];
@ -19,7 +21,7 @@ class Dijkstra {
$previous = [];
foreach ($vertices as $vertex) {
$dist[$vertex] = INF;
$previous[$vertex] = NULL;
$previous[$vertex] = null;
}
$dist[$source] = 0;
@ -30,7 +32,7 @@ class Dijkstra {
// TODO - Find faster way to get minimum
$min = INF;
foreach ($Q as $vertex){
foreach ($Q as $vertex) {
if ($dist[$vertex] < $min) {
$min = $dist[$vertex];
$u = $vertex;

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Graph;
use phpOMS\Stdlib\Map\KeyType;
use phpOMS\Stdlib\Map\MultiMap;
use phpOMS\Stdlib\Map\OrderType;
@ -149,8 +150,8 @@ class Graph
*/
public function removeEdgeById($id) : bool
{
if (isset($this->edge[$id])) {
unset($this->edge[$id]);
if (isset($this->edges[$id])) {
unset($this->edges[$id]);
return true;
}
@ -203,7 +204,7 @@ class Graph
*/
public function getEdgeById(int $id) : EdgeInterface
{
return $this->edges->get([$a, $b]) ?? new NullEdge();
return $this->edges->get($id) ?? new NullEdge();
}
/**

View File

@ -0,0 +1,33 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Graph;
/**
* Graph class
*
* @category Framework
* @package phpOMS\Asset
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class NullEdge
{
}

View File

@ -0,0 +1,33 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Graph;
/**
* Graph class
*
* @category Framework
* @package phpOMS\Asset
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class NullVertice
{
}

View File

@ -16,7 +16,6 @@
namespace phpOMS\Math\Shape\D2;
/**
* Polygon class.
*

View File

@ -15,6 +15,7 @@
*/
namespace phpOMS\Math\Stochastic\Distribution;
use phpOMS\Math\Functions;
/**

View File

@ -15,6 +15,7 @@
*/
namespace phpOMS\Math\Stochastic\Distribution;
use phpOMS\Math\Functions;
/**

View File

@ -151,7 +151,7 @@ class GeometricDistribution
*/
public static function getSkewness(float $lambda) : float
{
return (2 - $p) / sqrt(1 - $p);
return (2 - $lambda) / sqrt(1 - $lambda);
}
/**
@ -166,7 +166,7 @@ class GeometricDistribution
*/
public static function getExKurtosis(float $lambda) : float
{
return 6 + $p ** 2 / (1 - $p);
return 6 + $lambda ** 2 / (1 - $lambda);
}
public static function getRandom()

View File

@ -15,6 +15,7 @@
*/
namespace phpOMS\Math\Stochastic\Distribution;
use phpOMS\Math\Functions;
/**

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com
*/
namespace phpOMS\Message;
use phpOMS\DataStorage\Cookie\CookieJar;
use phpOMS\DataStorage\Session\HttpSession;

View File

@ -164,7 +164,7 @@ class Header extends HeaderAbstract
*/
public function generate(string $code)
{
switch($code) {
switch ($code) {
case RequestStatus::R_403:
$this->generate403();
break;

View File

@ -452,7 +452,7 @@ class Request extends RequestAbstract
*/
public function getRouteVerb() : int
{
switch($this->getMethod()) {
switch ($this->getMethod()) {
case RequestMethod::GET:
return RouteVerb::GET;
case RequestMethod::PUT:

View File

@ -110,7 +110,7 @@ class Response extends ResponseAbstract implements RenderableInterface
*/
public function render() : string
{
switch($this->header->get('Content-Type')) {
switch ($this->header->get('Content-Type')) {
case MimeType::M_JSON:
return $this->getJson();
default:
@ -154,7 +154,6 @@ class Response extends ResponseAbstract implements RenderableInterface
$render .= json_encode($response);
// TODO: remove this. This should never happen since then someone forgot to set the correct header. it should be json header!
} else {
var_dump($response);
throw new \Exception('Wrong response type');
}
}
@ -169,14 +168,14 @@ class Response extends ResponseAbstract implements RenderableInterface
{
$result = [];
foreach($this->response as $key => $response) {
if($response instanceof View) {
foreach ($this->response as $key => $response) {
if ($response instanceof View) {
$result += $response->toArray();
} elseif(is_array($response)) {
} elseif (is_array($response)) {
$result += $response;
} elseif(is_scalar($response)) {
} elseif (is_scalar($response)) {
$result[] = $response;
} elseif($response instanceof \Serializable) {
} elseif ($response instanceof \Serializable) {
$result[] = $response->serialize();
} else {
throw new \Exception('Wrong response type');

View File

@ -44,7 +44,8 @@ class Rest
* @since 1.0.0
* @author Dennis Eichhorn
*/
public function setRequest(Request $request) {
public function setRequest(Request $request)
{
$this->request = $request;
}

View File

@ -40,11 +40,13 @@ class Imap extends Mail
return !($this->inbox === false);
}
public function getBoxes() {
public function getBoxes()
{
return imap_list($this->inbox, $this->host, '*');
}
public function getQuota() {
public function getQuota()
{
return imap_get_quotaroot($this->inbox, "INBOX");
}
@ -133,10 +135,12 @@ class Imap extends Mail
{
if ($encoding == 3) {
return imap_base64($content);
} else if ($encoding == 1) {
} else {
if ($encoding == 1) {
return imap_8bit($content);
} else {
return imap_qprint($content);
}
}
}
}

View File

@ -211,7 +211,8 @@ abstract class RequestAbstract implements MessageInterface
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setMethod(string $method) {
public function setMethod(string $method)
{
$this->method = $method;
}
@ -261,6 +262,7 @@ abstract class RequestAbstract implements MessageInterface
public function getData($key = null)
{
$key = mb_strtolower($key);
return !isset($key) ? $this->data : $this->data[$key] ?? null;
}

View File

@ -83,6 +83,8 @@ class InfoManager
/**
* Update info file
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn
*/

View File

@ -65,7 +65,7 @@ class InstallerAbstract
*/
private static function installRoutes(string $destRoutePath, string $srcRoutePath)
{
if(file_exists($destRoutePath) && file_exists($srcRoutePath)) {
if (file_exists($destRoutePath) && file_exists($srcRoutePath)) {
/** @noinspection PhpIncludeInspection */
$appRoutes = include $destRoutePath;
/** @noinspection PhpIncludeInspection */
@ -73,7 +73,7 @@ class InstallerAbstract
$appRoutes = array_merge_recursive($appRoutes, $moduleRoutes);
if(is_writable($destRoutePath)) {
if (is_writable($destRoutePath)) {
file_put_contents($destRoutePath, '<?php return ' . ArrayParser::serializeArray($appRoutes) . ';', LOCK_EX);
} else {
throw new PermissionException($destRoutePath);

View File

@ -124,5 +124,5 @@ class ModuleFactory
self::$loaded[$name]->addReceiving($providing);
}
}
}
}
}

View File

@ -314,10 +314,10 @@ class ModuleManager
foreach ($installed as $key => $value) {
$this->installProviding($key, $module);
}
} catch(PathException $e) {
} catch (PathException $e) {
// todo: handle module doesn't exist or files are missing
//echo $e->getMessage();
} catch(\Exception $e) {
} catch (\Exception $e) {
//echo $e->getMessage();
}
}
@ -408,7 +408,7 @@ class ModuleManager
{
$class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer';
if(!Autoloader::exists($class)) {
if (!Autoloader::exists($class)) {
throw new \Exception('Module installer does not exist');
}

View File

@ -16,7 +16,6 @@
namespace phpOMS\Pattern;
/**
* Observer.
*

View File

@ -16,7 +16,6 @@
namespace phpOMS\Pattern;
/**
* Subject.
*

View File

@ -48,35 +48,43 @@ class ClientConnection
return $this->id;
}
public function getSocket() {
public function getSocket()
{
return $this->socket;
}
public function getHandshake() {
public function getHandshake()
{
return $this->handshake;
}
public function getPid() {
public function getPid()
{
return $this->pid;
}
public function isConnected() {
public function isConnected()
{
return $this->connected;
}
public function setSocket($socket) {
public function setSocket($socket)
{
$this->socket = $socket;
}
public function setHandshake($handshake) {
public function setHandshake($handshake)
{
$this->handshake = $handshake;
}
public function setPid($pid) {
public function setPid($pid)
{
$this->pid = $pid;
}
public function setConnected(bool $connected) {
public function setConnected(bool $connected)
{
$this->connected = $connected;
}
}

View File

@ -16,7 +16,6 @@
namespace phpOMS\Socket\Packets;
/**
* Server class.
*

View File

@ -33,9 +33,10 @@ class ClientManager
return $this->clients[$id] ?? new NullClientConnection(uniqid(), null);
}
public function getBySocket($socket) {
foreach($this->clients as $client) {
if($client->getSocket() === $socket) {
public function getBySocket($socket)
{
foreach ($this->clients as $client) {
if ($client->getSocket() === $socket) {
return $client;
}
}
@ -43,8 +44,9 @@ class ClientManager
return new NullClientConnection(uniqid(), null);
}
public function remove($id) {
if(isset($this->clients[$id])) {
public function remove($id)
{
if (isset($this->clients[$id])) {
unset($this->clients[$id]);
return true;

View File

@ -146,6 +146,7 @@ class Server extends SocketAbstract
$origin = $match[1];
}
$key = '';
if (preg_match("/Sec-WebSocket-Key: (.*)\r\n/", $headers, $match)) {
$key = $match[1];
}
@ -159,6 +160,7 @@ class Server extends SocketAbstract
"\r\n\r\n";
socket_write($client->getSocket(), $upgrade);
$client->setHandshake(true);
return true;
} else {
return false;

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com
*/
namespace phpOMS\Stdlib\Map;
use phpOMS\Utils\Permutation;
/**

View File

@ -199,7 +199,14 @@ class PriorityQueue implements \Countable, \Serializable
}
/**
* {@inheritdoc}
* Unserialize queue.
*
* @param string $data Data to unserialze
*
* @return array
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function unserialize($data) : array
{

View File

@ -71,13 +71,15 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
if ($filename != ".." && $filename != ".") {
if (is_dir($dir . "/" . $filename) && $recursive) {
$countSize += self::getFolderSize($dir . "/" . $filename, $recursive);
} else if (is_file($dir . "/" . $filename)) {
} else {
if (is_file($dir . "/" . $filename)) {
$countSize += filesize($dir . "/" . $filename);
$count++;
}
}
}
}
}
return (int) $countSize;
}
@ -216,7 +218,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
parent::__construct($path);
if (file_exists($this->path)) {
parent::index();
$this->index();
}
}
@ -287,6 +289,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
$this->size -= $this->nodes[$name]->getSize();
unset($this->nodes[$name]);
// todo: unlink???
return true;

View File

@ -26,7 +26,8 @@ namespace phpOMS\System;
* @link http://orange-management.com
* @since 1.0.0
*/
final class OperatingSystem {
final class OperatingSystem
{
/**
* Get OS.
*

View File

@ -59,7 +59,7 @@ class SystemUtils
$mem = 0;
while ($line = fgets($fh)) {
$pieces = array();
$pieces = [];
if (preg_match('/^MemTotal:\s+(\d+)\skB$/', $line, $pieces)) {
$mem = $pieces[1] * 1024;
break;

View File

@ -2,23 +2,28 @@
class Aztec
{
private function calculateSize() {
private function calculateSize()
{
}
private function bitStuffing() {
private function bitStuffing()
{
}
private function padding() {
private function padding()
{
}
private function check() {
private function check()
{
}
private function arange() {
private function arange()
{
}
}

View File

@ -81,7 +81,7 @@ abstract class C128Abstract
/**
* Barcode dimension.
*
* @todo: Implement!
* @todo : Implement!
*
* @var int[]
* @since 1.0.0
@ -135,7 +135,7 @@ abstract class C128Abstract
* @param int $size Barcode height
* @param int $orientation Orientation of the barcode
*
* @todo: add mirror parameter
* @todo : add mirror parameter
*
* @since 1.0.0
* @author Dennis Eichhorn

View File

@ -88,7 +88,7 @@ class C128a extends C128Abstract
* @param int $size Barcode height
* @param int $orientation Orientation of the barcode
*
* @todo: add mirror parameter
* @todo : add mirror parameter
*
* @since 1.0.0
* @author Dennis Eichhorn
@ -103,7 +103,7 @@ class C128a extends C128Abstract
*
* @param string $content Content to encrypt
*
* @todo: add mirror parameter
* @todo : add mirror parameter
*
* @since 1.0.0
* @author Dennis Eichhorn

View File

@ -71,7 +71,7 @@ class C25 extends C128Abstract
* @param int $size Barcode height
* @param int $orientation Orientation of the barcode
*
* @todo: add mirror parameter
* @todo : add mirror parameter
*
* @since 1.0.0
* @author Dennis Eichhorn

View File

@ -70,7 +70,7 @@ class C39 extends C128Abstract
* @param int $size Barcode height
* @param int $orientation Orientation of the barcode
*
* @todo: add mirror parameter
* @todo : add mirror parameter
*
* @since 1.0.0
* @author Dennis Eichhorn

View File

@ -71,7 +71,7 @@ class Codebar extends C128Abstract
* @param int $size Barcode height
* @param int $orientation Orientation of the barcode
*
* @todo: add mirror parameter
* @todo : add mirror parameter
*
* @since 1.0.0
* @author Dennis Eichhorn
@ -110,10 +110,11 @@ class Codebar extends C128Abstract
for ($posX = 1; $posX <= $length; $posX++) {
for ($posY = 0; $posY < $lenCodearr; $posY++) {
if (substr($this->content, ($posX - 1), 1) == self::$CODEARRAY[$posY])
if (substr($this->content, ($posX - 1), 1) == self::$CODEARRAY[$posY]) {
$codeString .= self::$CODEARRAY2[$posY] . '1';
}
}
}
return $codeString;
}

View File

@ -47,9 +47,9 @@ class LZW implements CompressionInterface
$length = strlen($source);
for ($i = 0; $i < $length; $i++) {
$c = $source[$i];
$wc = $w.$c;
$wc = $w . $c;
if (array_key_exists($w. $c, $dictionary)) {
if (array_key_exists($w . $c, $dictionary)) {
$w = $w . $c;
} else {
array_push($result, $dictionary[$w]);
@ -59,10 +59,10 @@ class LZW implements CompressionInterface
}
if ($w !== '') {
array_push($result,$dictionary[$w]);
array_push($result, $dictionary[$w]);
}
return implode(',',$result);
return implode(',', $result);
}
/**
@ -83,14 +83,14 @@ class LZW implements CompressionInterface
$result = $w;
$count = count($compressed);
for ($i = 1; $i < $count;$i++) {
for ($i = 1; $i < $count; $i++) {
$k = $compressed[$i];
if ($dictionary[$k]) {
$entry = $dictionary[$k];
} else {
if ($k === $dictSize) {
$entry = $w.$w[0];
$entry = $w . $w[0];
} else {
return null;
}

View File

@ -26,7 +26,8 @@ namespace phpOMS\Utils\Encoding;
* @link http://orange-management.com
* @since 1.0.0
*/
class Caesar {
class Caesar
{
/**
* ASCII lower char limit.
*
@ -50,16 +51,16 @@ class Caesar {
{
$result = '';
$length = strlen($source);
$keyLength = strlen($key)-1;
$keyLength = strlen($key) - 1;
for($i = 0, $j = 0; $i < $length; $i++, $j++) {
if($j > $keyLength) {
for ($i = 0, $j = 0; $i < $length; $i++, $j++) {
if ($j > $keyLength) {
$j = 0;
}
$ascii = ord($source[$i]) + ord($key[$j]);
if($ascii > self::LIMIT_UPPER) {
if ($ascii > self::LIMIT_UPPER) {
$ascii -= self::LIMIT_UPPER;
}
@ -76,16 +77,16 @@ class Caesar {
{
$result = '';
$length = strlen($raw);
$keyLength = strlen($key)-1;
$keyLength = strlen($key) - 1;
for($i = 0, $j = 0; $i < $length; $i++, $j++) {
if($j > $keyLength) {
for ($i = 0, $j = 0; $i < $length; $i++, $j++) {
if ($j > $keyLength) {
$j = 0;
}
$ascii = ord($raw[$i]) - ord($key[$j]);
if($ascii < self::LIMIT_LOWER) {
if ($ascii < self::LIMIT_LOWER) {
$ascii += self::LIMIT_LOWER;
}

View File

@ -26,7 +26,8 @@ namespace phpOMS\Utils\Encoding;
* @link http://orange-management.com
* @since 1.0.0
*/
final class Gray {
final class Gray
{
/**
* {@inheritdoc}
*/

View File

@ -26,7 +26,8 @@ namespace phpOMS\Utils\Encoding;
* @link http://orange-management.com
* @since 1.0.0
*/
final class XorEncoding {
final class XorEncoding
{
/**
* {@inheritdoc}
@ -35,10 +36,10 @@ final class XorEncoding {
{
$result = '';
$length = strlen($source);
$keyLength = strlen($key)-1;
$keyLength = strlen($key) - 1;
for($i = 0, $j = 0; $i < $length; $i++, $j++) {
if($j > $keyLength) {
for ($i = 0, $j = 0; $i < $length; $i++, $j++) {
if ($j > $keyLength) {
$j = 0;
}

View File

@ -25,6 +25,7 @@ require_once realpath(__DIR__ . '/../../../vendor/PHPExcel/Classes/PHPExcel.php'
* @package phpOMS\Utils\Excel
* @since 1.0.0
*/
/** @noinspection PhpUndefinedClassInspection */
class Excel extends \PHPExcel
{

View File

@ -53,7 +53,7 @@ class Author
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct(string $name, string $email)
public function __construct(string $name = '', string $email = '')
{
$this->name = $name;
$this->email = $email;
@ -69,7 +69,7 @@ class Author
*/
public function getName() : string
{
return $name;
return $this->name;
}
/**
@ -82,6 +82,6 @@ class Author
*/
public function getEmail() : string
{
return $email;
return $this->email;
}
}

View File

@ -44,7 +44,7 @@ class Branch
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct(string $name)
public function __construct(string $name = '')
{
$this->name = $name;
}

View File

@ -14,7 +14,6 @@
* @link http://orange-management.com
*/
namespace phpOMS\Utils\Git;
use phpDocumentor\Reflection\DocBlock\Tag;
/**
* Gray encoding class
@ -101,10 +100,11 @@ class Commit
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct(string $id = '') {
$author = new Author();
$branch = new Branch();
$tag = new Tag();
public function __construct(string $id = '')
{
$this->author = new Author();
$this->branch = new Branch();
$this->tag = new Tag();
if (!empty($id)) {
// todo: fill base info
@ -119,7 +119,8 @@ class Commit
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function addFile(string $path) {
public function addFile(string $path)
{
if (!isset($this->files[$path])) {
$this->files[$path] = [];
}
@ -247,7 +248,8 @@ class Commit
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setBranch(Branch $branch) {
public function setBranch(Branch $branch)
{
$this->branch = $branch;
}
@ -272,7 +274,8 @@ class Commit
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setTag(Tag $tag) {
public function setTag(Tag $tag)
{
$this->tag = $tag;
}

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com
*/
namespace phpOMS\Utils\Git;
use phpOMS\System\File\PathException;
/**
@ -27,7 +28,8 @@ use phpOMS\System\File\PathException;
* @link http://orange-management.com
* @since 1.0.0
*/
class Git {
class Git
{
/**
* Git path.
*

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com
*/
namespace phpOMS\Utils\Git;
use phpOMS\System\File\PathException;
/**
@ -125,6 +126,8 @@ class Repository
*
* @param string $cmd Command to run
*
* @return string
*
* @throws \Exception
*
* @since 1.0.0

View File

@ -0,0 +1,32 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Utils\Git;
/**
* Gray encoding class
*
* @category Framework
* @package phpOMS\Asset
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Tag
{
}

View File

@ -15,9 +15,13 @@
*/
namespace phpOMS\Utils\IO;
interface IODatabaseMapper {
interface IODatabaseMapper
{
public function addSource(string $source);
public function setSources(array $sources);
public function setLineBuffer(int $buffer);
public function insert();
}

View File

@ -25,6 +25,7 @@ include __DIR__ . '/../../../Resources/tcpdf/tcpdf.php';
* @package phpOMS\Utils\Pdf
* @since 1.0.0
*/
/** @noinspection PhpUndefinedClassInspection */
class Pdf extends \TCPDF
{

File diff suppressed because it is too large Load Diff

View File

@ -58,7 +58,9 @@ class ClassParser
private $functions = [];
public function __construct() {}
public function __construct()
{
}
/**
* Saving class to file.
@ -154,7 +156,8 @@ class ClassParser
return false;
}
public function setName(string $name) {
public function setName(string $name)
{
$this->name = $name;
}

View File

@ -46,7 +46,8 @@ class FunctionParser
private $body = '';
public function setName(string $name) {
public function setName(string $name)
{
$this->name = $name;
}
@ -55,7 +56,8 @@ class FunctionParser
return $this->name;
}
public function seBody(string $body) {
public function seBody(string $body)
{
$this->body = $body;
}
@ -79,7 +81,8 @@ class FunctionParser
return $this->visibility;
}
public function setStatic(bool $static) {
public function setStatic(bool $static)
{
$this->isStatic = $static;
}

View File

@ -40,7 +40,8 @@ class MemberParser
private $default = null;
public function setName(string $name) {
public function setName(string $name)
{
$this->name = $name;
}
@ -59,7 +60,8 @@ class MemberParser
return $this->visibility;
}
public function setStatic(bool $static) {
public function setStatic(bool $static)
{
$this->isStatic = $static;
if ($this->isStatic) {
@ -81,7 +83,8 @@ class MemberParser
}
}
public function setDefault($default) {
public function setDefault($default)
{
$this->default = $default;
}

View File

@ -107,16 +107,16 @@ class Permutation
*/
public static function permutate($toPermute, array $key)
{
if(!is_array($toPermute) || !is_string($toPermute)) {
if (!is_array($toPermute) || !is_string($toPermute)) {
throw new \Exception();
}
if(count($key) > strlen($toPermute)) {
if (count($key) > strlen($toPermute)) {
throw new \Exception();
}
$i = 0;
foreach($key as $pos) {
foreach ($key as $pos) {
$temp = $toPermute[$i];
$toPermute[$i] = $toPermute[$pos];
$toPermute[$pos] = $temp;

View File

@ -16,7 +16,6 @@
namespace phpOMS\Utils\RnG;
/**
* File generator.
*

View File

@ -41,7 +41,7 @@ class LinearCongruentialGenerator
*/
public static function bsd(int $seed)
{
return function() use(&$seed) {
return function () use (&$seed) {
return $seed = (1103515245 * $seed + 12345) % (1 << 31);
};
}
@ -56,8 +56,9 @@ class LinearCongruentialGenerator
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function msvcrt(int $seed) {
return function() use (&$seed) {
public static function msvcrt(int $seed)
{
return function () use (&$seed) {
return ($seed = (214013 * $seed + 2531011) % (1 << 31)) >> 16;
};
}

View File

@ -16,7 +16,6 @@
namespace phpOMS\Utils\RnG;
/**
* Phone generator.
*

View File

@ -28,7 +28,8 @@ namespace phpOMS\Utils\TaskSchedule;
*/
class Cron implements ScheduleInterface
{
public function __construct() {
public function __construct()
{
}

View File

@ -208,7 +208,8 @@ class Interval
}
public function setStart(\DateTime $start) {
public function setStart(\DateTime $start)
{
$this->start = $start;
}
@ -222,7 +223,8 @@ class Interval
return $this->end;
}
public function setEnd(\DateTime $end) {
public function setEnd(\DateTime $end)
{
$this->end = $end;
}

View File

@ -5,10 +5,11 @@ namespace phpOMS\Utils\TaskSchedule;
use phpOMS\System\OperatingSystem;
use phpOMS\System\SystemType;
final class SchedulerFactory {
final class SchedulerFactory
{
public static function create() : ScheduleInterface
{
switch(OperatingSystem::getSystem()) {
switch (OperatingSystem::getSystem()) {
case SystemType::WIN:
return new TaskScheduler();
case SystemType::LINUX:

View File

@ -5,10 +5,11 @@ namespace phpOMS\Utils\TaskSchedule;
use phpOMS\System\OperatingSystem;
use phpOMS\System\SystemType;
final class TaskFactory {
final class TaskFactory
{
public static function create(Interval $interval = null, string $cmd = '') : TaskInterface
{
switch(OperatingSystem::getSystem()) {
switch (OperatingSystem::getSystem()) {
case SystemType::WIN:
return new Schedule($interval, $cmd);
case SystemType::LINUX:

View File

@ -29,5 +29,6 @@ namespace phpOMS\Utils\TaskSchedule;
interface TaskInterface
{
public function setInterval(Interval $interval);
public function setCommand(string $command);
}

View File

@ -28,7 +28,8 @@ namespace phpOMS\Utils\TaskSchedule;
*/
class TaskScheduler implements ScheduleInterface
{
public function __construct() {
public function __construct()
{
}

View File

@ -16,7 +16,6 @@
namespace phpOMS\Validation;
/**
* Validator abstract.
*

View File

@ -16,7 +16,6 @@
namespace phpOMS\Validation;
/**
* Validator abstract.
*
@ -72,8 +71,10 @@ abstract class CreditCard extends ValidatorAbstract
return ($total % 10 == 0) ? true : false;
}
public static function luhnTest(string $num) {
public static function luhnTest(string $num)
{
$len = strlen($num);
$sum = 0;
for ($i = $len - 1; $i >= 0; $i--) {
$ord = ord($num[$i]);

View File

@ -16,7 +16,6 @@
namespace phpOMS\Validation;
/**
* Validator abstract.
*

View File

@ -16,7 +16,6 @@
namespace phpOMS\Validation;
/**
* Validator abstract.
*

View File

@ -16,7 +16,6 @@
namespace phpOMS\Validation;
/**
* Validator abstract.
*

View File

@ -16,7 +16,6 @@
namespace phpOMS\Validation;
/**
* Model validation trait.
*

View File

@ -271,7 +271,7 @@ class View implements \Serializable
$data = include $path;
$ob = ob_get_clean();
if(is_array($data)) {
if (is_array($data)) {
return $data;
}
@ -354,7 +354,7 @@ class View implements \Serializable
$viewArray[] = $this->render();
foreach($this->views as $key => $view) {
foreach ($this->views as $key => $view) {
$viewArray[$key] = $view->toArray();
}
}