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'); $this->lastActive = new \DateTime('NOW');
} }
public function setCreatedAt(\DateTime $created) { public function setCreatedAt(\DateTime $created)
{
$this->createdAt = $created; $this->createdAt = $created;
} }

View File

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

View File

@ -30,8 +30,8 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class AccountStatus extends Enum abstract class AccountStatus extends Enum
{ {
const ACTIVE = 1; const ACTIVE = 1;
const INACTIVE = 2; const INACTIVE = 2;
const TIMEOUT = 3; const TIMEOUT = 3;
const BANNED = 4; const BANNED = 4;
} }

View File

@ -30,6 +30,6 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class AccountType extends Enum abstract class AccountType extends Enum
{ {
const USER = 0; const USER = 0;
const GROUP = 1; const GROUP = 1;
} }

View File

@ -30,7 +30,7 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class AssetType extends Enum abstract class AssetType extends Enum
{ {
const CSS = 'css'; const CSS = 'css';
const JS = 'js'; const JS = 'js';
const JSLATE = 'jslate'; const JSLATE = 'jslate';
} }

View File

@ -32,14 +32,14 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class LoginReturnType extends Enum abstract class LoginReturnType extends Enum
{ {
const OK = 0; /* Everything is ok and the user got authed */ const OK = 0; /* Everything is ok and the user got authed */
const FAILURE = 1; /* Authentication resulted in a unexpected failure */ const FAILURE = 1; /* Authentication resulted in a unexpected failure */
const WRONG_PASSWORD = 2; /* Authentication with wrong password */ const WRONG_PASSWORD = 2; /* Authentication with wrong password */
const WRONG_USERNAME = 3; /* Authentication with unknown user */ const WRONG_USERNAME = 3; /* Authentication with unknown user */
const WRONG_PERMISSION = 4; /* User doesn't have permission to authenticate */ const WRONG_PERMISSION = 4; /* User doesn't have permission to authenticate */
const NOT_ACTIVATED = 5; /* The user is not activated yet */ const NOT_ACTIVATED = 5; /* The user is not activated yet */
const WRONG_INPUT_EXCEEDED = 6; /* Too many wrong logins recently */ const WRONG_INPUT_EXCEEDED = 6; /* Too many wrong logins recently */
const TIMEOUTED = 7; /* User received a timeout and can not log in until a certain date */ const TIMEOUTED = 7; /* User received a timeout and can not log in until a certain date */
const BANNED = 8; /* User is banned */ const BANNED = 8; /* User is banned */
const INACTIVE = 9; /* User is inactive */ const INACTIVE = 9; /* User is inactive */
} }

View File

@ -46,7 +46,7 @@ interface OptionsInterface
* *
* @param mixed $key Unique option key * @param mixed $key Unique option key
* @param mixed $value Option value * @param mixed $value Option value
* @param bool $overwrite Overwrite existing value * @param bool $overwrite Overwrite existing value
* *
* @return bool * @return bool
* *
@ -59,7 +59,7 @@ interface OptionsInterface
* Updating or adding settings. * Updating or adding settings.
* *
* @param array $pair Key value pair * @param array $pair Key value pair
* @param bool $overwrite Overwrite existing value * @param bool $overwrite Overwrite existing value
* *
* @return bool * @return bool
* *

View File

@ -120,8 +120,8 @@ abstract class SettingsAbstract implements OptionsInterface
/** /**
* Set option by key. * Set option by key.
* *
* @param string[] $options Column values for filtering * @param string[] $options Column values for filtering
* @param bool $store Save this Setting immediately to database * @param bool $store Save this Setting immediately to database
* *
* @return mixed Option value * @return mixed Option value
* *

View File

@ -57,8 +57,8 @@ class CommandManager implements \Countable
* Attach new command. * Attach new command.
* *
* @param string $cmd Command ID * @param string $cmd Command ID
* @param mixed $callback Function callback * @param mixed $callback Function callback
* @param mixed $source Provider * @param mixed $source Provider
* @param bool $overwrite Overwrite existing * @param bool $overwrite Overwrite existing
* *
* @return bool * @return bool
@ -82,7 +82,7 @@ class CommandManager implements \Countable
* Detach existing command. * Detach existing command.
* *
* @param string $cmd Command ID * @param string $cmd Command ID
* @param mixed $source Provider * @param mixed $source Provider
* *
* @return bool * @return bool
* *
@ -105,7 +105,7 @@ class CommandManager implements \Countable
* Trigger command. * Trigger command.
* *
* @param string $cmd Command ID * @param string $cmd Command ID
* @param mixed $para Parameters to pass * @param mixed $para Parameters to pass
* *
* @return mixed|bool * @return mixed|bool
* *

View File

@ -35,7 +35,7 @@ interface CacheInterface
* @param mixed $key Unique cache key * @param mixed $key Unique cache key
* @param mixed $value Cache value * @param mixed $value Cache value
* @param CacheStatus $type Cache type * @param CacheStatus $type Cache type
* @param int $expire Valid duration (in s) * @param int $expire Valid duration (in s)
* *
* @return void * @return void
* *
@ -50,7 +50,7 @@ interface CacheInterface
* @param mixed $key Unique cache key * @param mixed $key Unique cache key
* @param mixed $value Cache value * @param mixed $value Cache value
* @param CacheStatus $type Cache type * @param CacheStatus $type Cache type
* @param int $expire Valid duration (in s) * @param int $expire Valid duration (in s)
* *
* @return bool * @return bool
* *

View File

@ -32,10 +32,10 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class CacheStatus extends Enum abstract class CacheStatus extends Enum
{ {
const INACTIVE = 0; /* Caching is disabled */ const INACTIVE = 0; /* Caching is disabled */
const ERROR = 1; /* Caching failed */ const ERROR = 1; /* Caching failed */
const MEMCACHE = 2; /* Caching OK */ const MEMCACHE = 2; /* Caching OK */
const FILECACHE = 3; /* Caching OK */ const FILECACHE = 3; /* Caching OK */
const REDISCACHE = 4; /* Caching OK */ const REDISCACHE = 4; /* Caching OK */
const WINCACHE = 5; /* Caching OK */ const WINCACHE = 5; /* Caching OK */
} }

View File

@ -33,8 +33,8 @@ use phpOMS\Datatypes\Enum;
abstract class CacheType extends Enum abstract class CacheType extends Enum
{ {
const _NUMERIC = 0; /* Data is numeric */ const _NUMERIC = 0; /* Data is numeric */
const _STRING = 1; /* Data is string */ const _STRING = 1; /* Data is string */
const _ARRAY = 2; /* Data is array */ const _ARRAY = 2; /* Data is array */
const _OBJECT = 3; /* Data is object */ const _OBJECT = 3; /* Data is object */
const _HEX = 4; /* Data is object */ const _HEX = 4; /* Data is object */
} }

View File

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

View File

@ -75,13 +75,13 @@ class CookieJar
if (self::$isLocked) { if (self::$isLocked) {
throw new \Exception('Already locked'); throw new \Exception('Already locked');
} }
foreach ($this->cookies as $key => $cookie) { foreach ($this->cookies as $key => $cookie) {
setcookie($key, $cookie['value'], $cookie['expiry'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']); setcookie($key, $cookie['value'], $cookie['expiry'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
} }
} }
public static function lock() public static function lock()
{ {
self::$isLocked = true; self::$isLocked = true;
} }

View File

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

View File

@ -126,8 +126,8 @@ abstract class ConnectionAbstract implements ConnectionInterface
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getGrammar() : Grammar public function getGrammar() : Grammar
{ {
if (!isset($this->grammar)) { if (!isset($this->grammar)) {

View File

@ -262,7 +262,8 @@ abstract class DataMapperAbstract implements DataMapperInterface
return $this; return $this;
} }
public function clear() { public function clear()
{
$this->fields = []; $this->fields = [];
} }
@ -305,7 +306,7 @@ 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())
->into(static::$table); ->into(static::$table);
$reflectionClass = new \ReflectionClass(get_class($obj)); $reflectionClass = new \ReflectionClass(get_class($obj));
$properties = $reflectionClass->getProperties(); $properties = $reflectionClass->getProperties();
@ -361,12 +362,12 @@ abstract class DataMapperAbstract implements DataMapperInterface
$value = isset($value) ? json_encode($value) : ''; $value = isset($value) ? json_encode($value) : '';
} elseif ($column['type'] === 'Serializable') { } elseif ($column['type'] === 'Serializable') {
$value = $value->serialize(); $value = $value->serialize();
} elseif(is_object($value)) { } elseif (is_object($value)) {
$value = $value->getId(); $value = $value->getId();
} }
$query->insert($column['name']) $query->insert($column['name'])
->value($value, $column['type']); ->value($value, $column['type']);
break; break;
} }
} }
@ -442,8 +443,8 @@ abstract class DataMapperAbstract implements DataMapperInterface
/* is many->many */ /* is many->many */
$relQuery = new Builder($this->db); $relQuery = new Builder($this->db);
$relQuery->prefix($this->db->getPrefix()) $relQuery->prefix($this->db->getPrefix())
->into(static::$hasMany[$pname]['table']) ->into(static::$hasMany[$pname]['table'])
->insert(static::$hasMany[$pname]['src'], static::$hasMany[$pname]['dst']); ->insert(static::$hasMany[$pname]['src'], static::$hasMany[$pname]['dst']);
foreach ($objsIds as $key => $src) { foreach ($objsIds as $key => $src) {
$relQuery->values($src, $objId); $relQuery->values($src, $objId);
@ -489,7 +490,7 @@ 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())
->into(static::$table); ->into(static::$table);
$reflectionClass = new \ReflectionClass(get_class($obj)); $reflectionClass = new \ReflectionClass(get_class($obj));
$properties = $reflectionClass->getProperties(); $properties = $reflectionClass->getProperties();
@ -510,7 +511,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
} }
$query->update($column['name']) $query->update($column['name'])
->value($value); ->value($value);
break; break;
} }
} }
@ -551,7 +552,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
* Populate data. * Populate data.
* *
* @param array $result Result set * @param array $result Result set
* @param mixed $obj Object to populate * @param mixed $obj Object to populate
* *
* @return mixed * @return mixed
* *
@ -583,7 +584,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
* Is overwriting the hasOne id stored in the member variable by the object. * Is overwriting the hasOne id stored in the member variable by the object.
* todo: hasMany needs to be implemented somehow?!?! * todo: hasMany needs to be implemented somehow?!?!
* *
* @param $obj Object to add the relations to * @param $obj Object to add the relations to
* @param int $relations Relations type * @param int $relations Relations type
* *
* @return mixed * @return mixed
@ -740,7 +741,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
* Get object. * Get object.
* *
* @param mixed $primaryKey Key * @param mixed $primaryKey Key
* @param int $relations Load relations * @param int $relations Load relations
* @param mixed $fill Object to fill * @param mixed $fill Object to fill
* *
* @return mixed * @return mixed
@ -814,9 +815,9 @@ abstract class DataMapperAbstract implements DataMapperInterface
* *
* This will fall back to the insert id if no datetime column is present. * This will fall back to the insert id if no datetime column is present.
* *
* @param int $limit Newest limit * @param int $limit Newest limit
* @param Builder $query Pre-defined query * @param Builder $query Pre-defined query
* @param int $relations Load relations * @param int $relations Load relations
* *
* @return mixed * @return mixed
* *
@ -827,9 +828,9 @@ abstract class DataMapperAbstract implements DataMapperInterface
{ {
$query = $query ?? new Builder($this->db); $query = $query ?? new Builder($this->db);
$query->prefix($this->db->getPrefix()) $query->prefix($this->db->getPrefix())
->select('*') ->select('*')
->from(static::$table) ->from(static::$table)
->limit($limit); /* todo: limit is not working, setting this to 2 doesn't have any effect!!! */ ->limit($limit); /* todo: limit is not working, setting this to 2 doesn't have any effect!!! */
if (!empty(static::$createdAt)) { if (!empty(static::$createdAt)) {
$query->orderBy(static::$table . '.' . static::$columns[static::$createdAt]['name'], 'DESC'); $query->orderBy(static::$table . '.' . static::$columns[static::$createdAt]['name'], 'DESC');
@ -841,7 +842,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
$sth->execute(); $sth->execute();
$results = $sth->fetchAll(\PDO::FETCH_ASSOC); $results = $sth->fetchAll(\PDO::FETCH_ASSOC);
$obj = $this->populateIterable(is_bool($results) ? [] : $results); $obj = $this->populateIterable(is_bool($results) ? [] : $results);
$this->fillRelations($obj, $relations); $this->fillRelations($obj, $relations);
$this->clear(); $this->clear();
@ -853,8 +854,8 @@ abstract class DataMapperAbstract implements DataMapperInterface
/** /**
* Get all by custom query. * Get all by custom query.
* *
* @param Builder $query Query * @param Builder $query Query
* @param bool $relations Relations * @param bool $relations Relations
* *
* @return array * @return array
* *
@ -886,7 +887,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getRandom(int $relations = RelationType::ALL) public function getRandom(int $relations = RelationType::ALL)
{ {
// todo: implement // todo: implement
} }
@ -894,15 +895,15 @@ abstract class DataMapperAbstract implements DataMapperInterface
/** /**
* Fill object with relations * Fill object with relations
* *
* @param mixed $obj Objects to fill * @param mixed $obj Objects to fill
* @param int $relations Relations type * @param int $relations Relations type
* *
* @return array * @return array
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function fillRelations(array &$obj, int $relations = RelationType::ALL) public function fillRelations(array &$obj, int $relations = RelationType::ALL)
{ {
$hasMany = count(static::$hasMany) > 0; $hasMany = count(static::$hasMany) > 0;
$hasOne = count(static::$hasOne) > 0; $hasOne = count(static::$hasOne) > 0;
@ -942,9 +943,9 @@ 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())
->select('*') ->select('*')
->from(static::$table) ->from(static::$table)
->where(static::$table . '.' . static::$primaryField, '=', $primaryKey); ->where(static::$table . '.' . static::$primaryField, '=', $primaryKey);
$sth = $this->db->con->prepare($query->toSql()); $sth = $this->db->con->prepare($query->toSql());
$sth->execute(); $sth->execute();
@ -968,8 +969,8 @@ 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())
->select('*') ->select('*')
->from(static::$table); ->from(static::$table);
$sth = $this->db->con->prepare($query->toSql()); $sth = $this->db->con->prepare($query->toSql());
$sth->execute(); $sth->execute();
@ -983,7 +984,7 @@ abstract class DataMapperAbstract implements DataMapperInterface
* Get raw by primary key * Get raw by primary key
* *
* @param mixed $primaryKey Primary key * @param mixed $primaryKey Primary key
* @param int $relations Load relations * @param int $relations Load relations
* *
* @return array * @return array
* *
@ -1001,27 +1002,27 @@ abstract class DataMapperAbstract implements DataMapperInterface
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.*
FROM customer c FROM customer c
JOIN purchase p1 ON (c.id = p1.customer_id) JOIN purchase p1 ON (c.id = p1.customer_id)
LEFT OUTER JOIN purchase p2 ON (c.id = p2.customer_id AND 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)) (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']) $query->select(static::$table . '.' . static::$primaryField, $value['table'] . '.' . $value['src'])
->from(static::$table) ->from(static::$table)
->join($value['table']) ->join($value['table'])
->on(static::$table . '.' . static::$primaryField, '=', $value['table'] . '.' . $value['dst']) ->on(static::$table . '.' . static::$primaryField, '=', $value['table'] . '.' . $value['dst'])
->leftOuterJoin($value['table']) ->leftOuterJoin($value['table'])
->on(new And('1', new And(new Or('d1', 'd2'), 'id'))) ->on(new And('1', new And(new Or('d1', 'd2'), 'id')))
->where($value['table'] . '.' . $value['dst'], '=', 'NULL'); ->where($value['table'] . '.' . $value['dst'], '=', 'NULL');
*/ */
} }
$sth = $this->db->con->prepare($query->toSql()); $sth = $this->db->con->prepare($query->toSql());

View File

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

View File

@ -32,10 +32,10 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class DatabaseStatus extends Enum abstract class DatabaseStatus extends Enum
{ {
const OK = 0; /* Database connection successful */ const OK = 0; /* Database connection successful */
const MISSING_DATABASE = 1; /* Couldn't find database */ const MISSING_DATABASE = 1; /* Couldn't find database */
const MISSING_TABLE = 2; /* One of the core tables couldn't be found */ const MISSING_TABLE = 2; /* One of the core tables couldn't be found */
const FAILURE = 3; /* Unknown failure */ const FAILURE = 3; /* Unknown failure */
const READONLY = 4; /* Database connection is in readonly (but ok) */ const READONLY = 4; /* Database connection is in readonly (but ok) */
const CLOSED = 5; /* Database connection closed */ const CLOSED = 5; /* Database connection closed */
} }

View File

@ -32,9 +32,9 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class DatabaseType extends Enum abstract class DatabaseType extends Enum
{ {
const MYSQL = 0; /* MySQL */ const MYSQL = 0; /* MySQL */
const SQLITE = 1; /* SQLITE */ const SQLITE = 1; /* SQLITE */
const PGSQL = 2; /* PostgreSQL */ const PGSQL = 2; /* PostgreSQL */
const ORACLE = 3; /* Oracle */ const ORACLE = 3; /* Oracle */
const SQLSRV = 4; /* Microsoft SQL Server */ const SQLSRV = 4; /* Microsoft SQL Server */
} }

View File

@ -89,7 +89,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 !== '';
} }
) )
@ -102,7 +102,7 @@ abstract class GrammarAbstract
/** /**
* Expressionize elements. * Expressionize elements.
* *
* @param array $elements Elements * @param array $elements Elements
* @param string $prefix Prefix for table * @param string $prefix Prefix for table
* *
* @return string * @return string

View File

@ -382,7 +382,7 @@ class Builder extends BuilderAbstract
* *
* @param string|array|\Closure $columns Columns * @param string|array|\Closure $columns Columns
* @param string|array $operator Operator * @param string|array $operator Operator
* @param mixed $values Values * @param mixed $values Values
* @param string|array $boolean Boolean condition * @param string|array $boolean Boolean condition
* *
* @return Builder * @return Builder
@ -429,7 +429,7 @@ class Builder extends BuilderAbstract
* Where in. * Where in.
* *
* @param string|array|\Closure $column Column * @param string|array|\Closure $column Column
* @param mixed $values Values * @param mixed $values Values
* @param string $boolean Boolean condition * @param string $boolean Boolean condition
* *
* @return Builder * @return Builder
@ -717,8 +717,8 @@ class Builder extends BuilderAbstract
/** /**
* Values to insert. * Values to insert.
* *
* @param mixed $value Values * @param mixed $value Values
* @param string $type Data type to insert * @param string $type Data type to insert
* *
* @return Builder * @return Builder
* *

View File

@ -172,7 +172,7 @@ class Grammar extends GrammarAbstract
* *
* @param Builder $query Builder * @param Builder $query Builder
* @param array $wheres Where elmenets * @param array $wheres Where elmenets
* @param bool $first Is first element (usefull for nesting) * @param bool $first Is first element (usefull for nesting)
* *
* @return string * @return string
* *
@ -222,7 +222,7 @@ class Grammar extends GrammarAbstract
* Compile value. * Compile value.
* *
* @param array|string|\Closure $value Value * @param array|string|\Closure $value Value
* @param string $prefix Prefix in case value is a table * @param string $prefix Prefix in case value is a table
* *
* @return string * @return string
* *
@ -262,7 +262,7 @@ class Grammar extends GrammarAbstract
* Compile limit. * Compile limit.
* *
* @param Builder $query Builder * @param Builder $query Builder
* @param int $limit Limit * @param int $limit Limit
* *
* @return string * @return string
* *
@ -278,7 +278,7 @@ class Grammar extends GrammarAbstract
* Compile offset. * Compile offset.
* *
* @param Builder $query Builder * @param Builder $query Builder
* @param int $offset Offset * @param int $offset Offset
* *
* @return string * @return string
* *
@ -361,7 +361,7 @@ class Grammar extends GrammarAbstract
* Compile insert into table. * Compile insert into table.
* *
* @param Builder $query Builder * @param Builder $query Builder
* @param string $table Table * @param string $table Table
* *
* @return string * @return string
* *

View File

@ -30,15 +30,15 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class JoinType extends Enum abstract class JoinType extends Enum
{ {
const JOIN = 'JOIN'; const JOIN = 'JOIN';
const LEFT_JOIN = 'LEFT JOIN'; const LEFT_JOIN = 'LEFT JOIN';
const LEFT_OUTER_JOIN = 'LEFT OUTER JOIN'; const LEFT_OUTER_JOIN = 'LEFT OUTER JOIN';
const LEFT_INNER_JOIN = 'LEFT INNER JOIN'; const LEFT_INNER_JOIN = 'LEFT INNER JOIN';
const RIGHT_JOIN = 'RIGHT JOIN'; const RIGHT_JOIN = 'RIGHT JOIN';
const RIGHT_OUTER_JOIN = 'RIGHT OUTER JOIN'; const RIGHT_OUTER_JOIN = 'RIGHT OUTER JOIN';
const RIGHT_INNER_JOIN = 'RIGHT INNER JOIN'; const RIGHT_INNER_JOIN = 'RIGHT INNER JOIN';
const OUTER_JOIN = 'OUTER JOIN'; const OUTER_JOIN = 'OUTER JOIN';
const INNER_JOIN = 'INNER JOIN'; const INNER_JOIN = 'INNER JOIN';
const CROSS_JOIN = 'CROSS JOIN'; const CROSS_JOIN = 'CROSS JOIN';
const FULL_OUTER_JOIN = 'FULL OUTER JOIN'; const FULL_OUTER_JOIN = 'FULL OUTER JOIN';
} }

View File

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

View File

@ -34,6 +34,6 @@ abstract class QueryType extends Enum
{ {
const SELECT = 0; const SELECT = 0;
const CREATE = 1; const CREATE = 1;
const DROP = 2; const DROP = 2;
const ALTER = 3; const ALTER = 3;
} }

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com * @link http://orange-management.com
*/ */
namespace phpOMS\DataStorage\Session; namespace phpOMS\DataStorage\Session;
use phpOMS\Uri\UriFactory; use phpOMS\Uri\UriFactory;
use phpOMS\Utils\RnG\StringUtils; use phpOMS\Utils\RnG\StringUtils;
@ -52,7 +53,7 @@ class HttpSession implements SessionInterface
/** /**
* Constructor. * Constructor.
* *
* @param int $liftetime Session life time * @param int $liftetime Session life time
* @param string|int|bool $sid Session id * @param string|int|bool $sid Session id
* *
* @throws \Exception * @throws \Exception
@ -73,7 +74,7 @@ class HttpSession implements SessionInterface
session_set_cookie_params($liftetime, '/', null, false, true); session_set_cookie_params($liftetime, '/', null, false, true);
session_start(); session_start();
$this->sessionData = $_SESSION; $this->sessionData = $_SESSION;
$_SESSION = null; $_SESSION = null;
$this->sid = session_id(); $this->sid = session_id();
$this->setCsrfProtection(); $this->setCsrfProtection();
@ -87,7 +88,7 @@ class HttpSession implements SessionInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
private function setCsrfProtection() private function setCsrfProtection()
{ {
$this->set('UID', 0, false); $this->set('UID', 0, false);
@ -170,7 +171,7 @@ class HttpSession implements SessionInterface
self::$isLocked = true; self::$isLocked = true;
} }
public static function isLocked() public static function isLocked()
{ {
return self::$isLocked; return self::$isLocked;
} }

View File

@ -47,8 +47,8 @@ interface SessionInterface
* Store session value by key. * Store session value by key.
* *
* @param string|int $key Value key * @param string|int $key Value key
* @param mixed $value Value to store * @param mixed $value Value to store
* @param bool $overwrite Overwrite existing values * @param bool $overwrite Overwrite existing values
* *
* @return bool * @return bool
* *

View File

@ -28,9 +28,9 @@ namespace phpOMS\Datatypes;
*/ */
abstract class AddressType extends Enum abstract class AddressType extends Enum
{ {
const HOME = 1; const HOME = 1;
const BUSINESS = 2; const BUSINESS = 2;
const SHIPPING = 3; const SHIPPING = 3;
const BILLING = 4; const BILLING = 4;
const WORK = 5; const WORK = 5;
} }

View File

@ -92,7 +92,7 @@ abstract class Enum
* @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 getRandom() public static function getRandom()
{ {
$constants = self::getConstants(); $constants = self::getConstants();

View File

@ -28,8 +28,8 @@ namespace phpOMS\Datatypes;
*/ */
abstract class PhoneType extends Enum abstract class PhoneType extends Enum
{ {
const HOME = 1; const HOME = 1;
const BUSINESS = 2; const BUSINESS = 2;
const MOBILE = 3; const MOBILE = 3;
const WORK = 4; const WORK = 4;
} }

View File

@ -30,13 +30,13 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class TagType extends Enum abstract class TagType extends Enum
{ {
const INPUT = 0; /* <input> */ const INPUT = 0; /* <input> */
const BUTTON = 1; /* <button> */ const BUTTON = 1; /* <button> */
const LINK = 2; /* <a> */ const LINK = 2; /* <a> */
const SYMMETRIC = 3; /* <span><div>... */ const SYMMETRIC = 3; /* <span><div>... */
const TEXTAREA = 4; /* <textarea> */ const TEXTAREA = 4; /* <textarea> */
const SELECT = 5; /* <select> */ const SELECT = 5; /* <select> */
const LABEL = 6; /* <label> */ const LABEL = 6; /* <label> */
const ULIST = 7; /* <ul> */ const ULIST = 7; /* <ul> */
const OLIST = 8; /* <ul> */ const OLIST = 8; /* <ul> */
} }

View File

@ -35,8 +35,8 @@ use phpOMS\Validation\Validator;
class FileLogger implements LoggerInterface class FileLogger implements LoggerInterface
{ {
const MSG_BACKTRACE = '{datetime}; {level}; {ip}; {message}; {backtrace}'; const MSG_BACKTRACE = '{datetime}; {level}; {ip}; {message}; {backtrace}';
const MSG_FULL = '{datetime}; {level}; {ip}; {line}; {version}; {os}; {path}; {message}; {file}; {backtrace}'; const MSG_FULL = '{datetime}; {level}; {ip}; {line}; {version}; {os}; {path}; {message}; {file}; {backtrace}';
const MSG_SIMPLE = '{datetime}; {level}; {ip}; {message};'; const MSG_SIMPLE = '{datetime}; {level}; {ip}; {message};';
/** /**
* Timing array. * Timing array.
@ -88,15 +88,15 @@ class FileLogger implements LoggerInterface
* *
* Creates the logging object and overwrites all default values. * Creates the logging object and overwrites all default values.
* *
* @param string $lpath Path for logging * @param string $lpath Path for logging
* @param bool $verbose Verbose logging * @param bool $verbose Verbose logging
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn * @author Dennis Eichhorn
*/ */
public function __construct(string $lpath, bool $verbose = false) public function __construct(string $lpath, bool $verbose = false)
{ {
$path = realpath($lpath); $path = realpath($lpath);
self::$verbose = $verbose; self::$verbose = $verbose;
if ($path !== false && Validator::startsWith($path, ROOT_PATH) === false) { if ($path !== false && Validator::startsWith($path, ROOT_PATH) === false) {
@ -262,12 +262,12 @@ class FileLogger implements LoggerInterface
* @param array $a * @param array $a
* @param array $b * @param array $b
* *
* @return bool the comparison * @return int
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn * @author Dennis Eichhorn
*/ */
private function orderSort($a, $b) private function orderSort($a, $b) : int
{ {
if ($a['time'] == $b['time']) { if ($a['time'] == $b['time']) {
return 0; return 0;
@ -297,7 +297,7 @@ class FileLogger implements LoggerInterface
} }
if (self::$verbose) { if (self::$verbose) {
echo $message , "\n"; echo $message, "\n";
} }
} }
@ -628,7 +628,7 @@ class FileLogger implements LoggerInterface
* Create console log. * Create console log.
* *
* @param string $message Log message * @param string $message Log message
* @param bool $verbose Is verbose * @param bool $verbose Is verbose
* @param array $context Context * @param array $context Context
* *
* @return array * @return array

View File

@ -31,11 +31,11 @@ use phpOMS\Datatypes\Enum;
abstract class LogLevel extends Enum abstract class LogLevel extends Enum
{ {
const EMERGENCY = 'emergency'; const EMERGENCY = 'emergency';
const ALERT = 'alert'; const ALERT = 'alert';
const CRITICAL = 'critical'; const CRITICAL = 'critical';
const ERROR = 'error'; const ERROR = 'error';
const WARNING = 'warning'; const WARNING = 'warning';
const NOTICE = 'notice'; const NOTICE = 'notice';
const INFO = 'info'; const INFO = 'info';
const DEBUG = 'debug'; const DEBUG = 'debug';
} }

View File

@ -33,7 +33,7 @@ interface LoggerInterface
* System is unusable. * System is unusable.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* *
* @return null * @return null
*/ */
@ -46,7 +46,7 @@ interface LoggerInterface
* trigger the SMS alerts and wake you up. * trigger the SMS alerts and wake you up.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* *
* @return null * @return null
*/ */
@ -58,7 +58,7 @@ interface LoggerInterface
* Example: Application component unavailable, unexpected exception. * Example: Application component unavailable, unexpected exception.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* *
* @return null * @return null
*/ */
@ -69,7 +69,7 @@ interface LoggerInterface
* be logged and monitored. * be logged and monitored.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* *
* @return null * @return null
*/ */
@ -82,7 +82,7 @@ interface LoggerInterface
* that are not necessarily wrong. * that are not necessarily wrong.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* *
* @return null * @return null
*/ */
@ -92,7 +92,7 @@ interface LoggerInterface
* Normal but significant events. * Normal but significant events.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* *
* @return null * @return null
*/ */
@ -104,7 +104,7 @@ interface LoggerInterface
* Example: User logs in, SQL logs. * Example: User logs in, SQL logs.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* *
* @return null * @return null
*/ */
@ -114,7 +114,7 @@ interface LoggerInterface
* Detailed debug information. * Detailed debug information.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* *
* @return null * @return null
*/ */
@ -125,7 +125,7 @@ interface LoggerInterface
* *
* @param string $level * @param string $level
* @param string $message * @param string $message
* @param array $context * @param array $context
* *
* @return null * @return null
*/ */

View File

@ -1005,7 +1005,7 @@ class FinanceFormulas
/** /**
* Net Present Value * Net Present Value
* *
* @param array $C Cash flow ($C[0] = initial investment) * @param array $C Cash flow ($C[0] = initial investment)
* @param float $r Discount rate * @param float $r Discount rate
* *
* @return float * @return float

View File

@ -31,7 +31,7 @@ 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
@ -44,10 +44,10 @@ class Fibunacci
$old_1 = 0; $old_1 = 0;
$old_2 = $start; $old_2 = $start;
$fib = 0; $fib = 0;
for ($i = 4; $i < $n; $i++) { for ($i = 4; $i < $n; $i++) {
$fib = $old_1 + $old_2; $fib = $old_1 + $old_2;
$old_1 = $old_2; $old_1 = $old_2;
$old_2 = $fib; $old_2 = $fib;
} }
@ -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)));
} }
} }

View File

@ -141,7 +141,7 @@ class Functions
/** /**
* Calculate inverse modular. * Calculate inverse modular.
* *
* @param int $a * @param int $a
* @param int $n Modulo * @param int $n Modulo
* *
* @return int * @return int
@ -149,28 +149,29 @@ 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;
} }
if ($a < 0) { if ($a < 0) {
$a = $n - (-$a % $n); $a = $n - (-$a % $n);
} }
$t = 0; $t = 0;
$nt = 1; $nt = 1;
$r = $n; $r = $n;
$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;
} }
if ($r > 1) { if ($r > 1) {

View File

@ -2,15 +2,16 @@
namespace phpOMS\Math\Matrix; namespace phpOMS\Math\Matrix;
class IdentityMatrix extends Matrix { class IdentityMatrix extends Matrix
public function __constrcut(int $n) {
public function __constrcut(int $n)
{ {
$this->n = $n; $this->n = $n;
$this->m = $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] = array_fill(0, $n, 0);
$this->matrix[$i][$i] = 1; $this->matrix[$i][$i] = 1;
} }
} }
} }

View File

@ -2,14 +2,14 @@
namespace phpOMS\Math\Matrix; namespace phpOMS\Math\Matrix;
class Matrix implements \ArrayAccess, \Iterator class Matrix implements \ArrayAccess, \Iterator
{ {
protected $matrix = []; protected $matrix = [];
protected $n = 0; protected $n = 0;
protected $m = 0; protected $m = 0;
public function __construct(int $m, int $n = 1) public function __construct(int $m, int $n = 1)
{ {
$this->n = $n; $this->n = $n;
$this->m = $m; $this->m = $m;
@ -17,7 +17,7 @@ class Matrix implements \ArrayAccess, \Iterator
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)
{ {
@ -71,8 +71,8 @@ class Matrix implements \ArrayAccess, \Iterator
throw new \Exception('Dimension'); throw new \Exception('Dimension');
} }
$matrixArr = $matrix->getMatrix(); $matrixArr = $matrix->getMatrix();
$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
@ -136,7 +136,7 @@ class Matrix implements \ArrayAccess, \Iterator
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) {
@ -167,17 +167,19 @@ class Matrix implements \ArrayAccess, \Iterator
return $newMatrix; return $newMatrix;
} }
public function upperTriangular() : Matrix public function upperTriangular() : Matrix
{ {
$matrix = new Matrix($this->n, $this->n); $matrix = new Matrix($this->n, $this->n);
$matrixArr = $this->matrix; $matrixArr = $this->matrix;
$matrix->setMatrix($this->upperTrianglize($matrixArr)); $this->upperTrianglize($matrixArr);
$matrix->setMatrix($matrixArr);
return $matrix; return $matrix;
} }
public function lowerTriangular() : Matrix public function lowerTriangular() : Matrix
{ {
// todo: implement // todo: implement
return new Matrix($this->m, $this->n); return new Matrix($this->m, $this->n);
@ -191,9 +193,9 @@ class Matrix implements \ArrayAccess, \Iterator
switch ($algorithm) { switch ($algorithm) {
case InversionType::GAUSS_JORDAN: case InversionType::GAUSS_JORDAN:
return $this->inverseGaussJordan(); return $this->inverseGaussJordan();
default: default:
throw new \Exception(''); throw new \Exception('');
} }
} }
@ -239,9 +241,9 @@ class Matrix implements \ArrayAccess, \Iterator
return $newMatrix; return $newMatrix;
} }
private function decompositionCholesky() : Matrix private function decompositionCholesky() : Matrix
{ {
$newMatrix = new Matrix($this->n, $this->n); $newMatrix = new Matrix($this->n, $this->n);
$newMatrixArr = $newMatrix->getMatrix(); $newMatrixArr = $newMatrix->getMatrix();
for ($i = 0; $i < $this->n; $i++) { for ($i = 0; $i < $this->n; $i++) {
@ -269,8 +271,8 @@ class Matrix implements \ArrayAccess, \Iterator
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;
} }
} }
@ -294,36 +296,36 @@ class Matrix implements \ArrayAccess, \Iterator
private function upperTrianglize(array &$arr) : int private function upperTrianglize(array &$arr) : int
{ {
$n = count($arr); $n = count($arr);
$sign = 1; $sign = 1;
for ($i = 0; $i < $n; $i++) { for ($i = 0; $i < $n; $i++) {
$max = 0; $max = 0;
for ($j = $i; $j < $n; $j++) { for ($j = $i; $j < $n; $j++) {
if (abs($arr[$j][$i]) > abs($arr[$max][$i])) { if (abs($arr[$j][$i]) > abs($arr[$max][$i])) {
$max = $j; $max = $j;
} }
} }
if ($max) { if ($max) {
$sign = -$sign; $sign = -$sign;
$temp = $arr[$i]; $temp = $arr[$i];
$arr[$i] = $arr[$max]; $arr[$i] = $arr[$max];
$arr[$max] = $temp; $arr[$max] = $temp;
} }
if (!$arr[$i][$i]) { if (!$arr[$i][$i]) {
return 0; return 0;
} }
for ($j = $i + 1; $j < $n; $j++) { for ($j = $i + 1; $j < $n; $j++) {
$r = $arr[$j][$i] / $arr[$i][$i]; $r = $arr[$j][$i] / $arr[$i][$i];
if (!$r) { if (!$r) {
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;
} }
@ -331,7 +333,7 @@ class Matrix implements \ArrayAccess, \Iterator
} }
return $sign; return $sign;
} }
public function det() public function det()
{ {
@ -340,7 +342,7 @@ class Matrix implements \ArrayAccess, \Iterator
} }
$trianglize = $this->matrix; $trianglize = $this->matrix;
$prod = $this->upperTrianglize($trianglize); $prod = $this->upperTrianglize($trianglize);
for ($i = 0; $i < $this->n; $i++) { for ($i = 0; $i < $this->n; $i++) {
$prod *= $trianglize[$i][$i]; $prod *= $trianglize[$i][$i];
@ -348,4 +350,122 @@ class Matrix implements \ArrayAccess, \Iterator
return $prod; 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,9 +2,10 @@
namespace phpOMS\Math\Matrix; namespace phpOMS\Math\Matrix;
class Vector extends Matrix { class Vector extends Matrix
public function __construct(int $m) {
public function __construct(int $m)
{ {
parent::__construct($m); parent::__construct($m);
} }
} }

View File

@ -1,14 +1,14 @@
<?php <?php
use phpOMS\Math\Number\Prime; use phpOMS\Math\Number\Prime;
class Integer implements Number class Integer
{ {
public static function isInteger($value) : bool public static function isInteger($value) : bool
{ {
return is_int($value); return is_int($value);
} }
/** /**
* Greatest common diviser. * Greatest common diviser.
* *
* @param int $n Number one * @param int $n Number one
@ -24,68 +24,69 @@ class Integer implements Number
while (true) { while (true) {
if ($n === $m) { if ($n === $m) {
return $m; return $m;
} if ($n > $m) { }
if ($n > $m) {
$n -= $m; $n -= $m;
} else { } else {
$m -= $n; $m -= $n;
} }
} }
return 1; return 1;
} }
public static function trialFactorization(int $value) public static function trialFactorization(int $value)
{ {
if ($value < 2) { if ($value < 2) {
return []; return [];
} }
$factors = []; $factors = [];
$primes = Prime::sieveOfEratosthenes((int) $value**0.5); $primes = Prime::sieveOfEratosthenes((int) $value ** 0.5);
foreach($primes as $prime) { foreach ($primes as $prime) {
if($prime*$prime > $value) { if ($prime * $prime > $value) {
break; break;
} }
while($value%$prime === 0) { while ($value % $prime === 0) {
$factors[] = $prime; $factors[] = $prime;
$value /= $prime; $value /= $prime;
} }
} }
if($value > 1) { if ($value > 1) {
$factors[] = $value; $factors[] = $value;
} }
return $factors; return $factors;
} }
public static function pollardsRho($value, $x = 2, $factor = 1, $cycleSize = 2, $xFixed = 2) public static function pollardsRho($value, $x = 2, $factor = 1, $cycleSize = 2, $xFixed = 2)
{ {
while($factor === 1) { while ($factor === 1) {
for($i = 1; $i < $cycleSize && $factor <= 1; $i++) { for ($i = 1; $i < $cycleSize && $factor <= 1; $i++) {
$x = ($x*$x+1)%$value; $x = ($x * $x + 1) % $value;
$factor = self::greatestCommonDivisor($x-$xFixed, $value); $factor = self::greatestCommonDivisor($x - $xFixed, $value);
} }
$cycleSize *= 2; $cycleSize *= 2;
$xFixed = $x; $xFixed = $x;
} }
return $factor; return $factor;
} }
public static function fermatFactor(int $value) public static function fermatFactor(int $value)
{ {
$a = $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; $a += 1;
$b2 = $a*$a - $value; $b2 = $a * $a - $value;
} }
return $a - sqrt($b2); return $a - sqrt($b2);
} }
} }

View File

@ -1,9 +1,9 @@
<?php <?php
class Natural implements Number class Natural
{ {
public static function isNatural($value) : bool public static function isNatural($value) : bool
{ {
return is_int($value) && $value >= 0; return is_int($value) && $value >= 0;
} }
} }

View File

@ -1,5 +1,9 @@
class Number { <?php
public static function getType($number) {
} 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

@ -62,15 +62,15 @@ class Numbers
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn * @author Dennis Eichhorn
*/ */
public static function selfdescribing(int $n) : bool public static function selfdescribing(int $n) : bool
{ {
$split = str_split($n); $split = str_split($n);
foreach ($split as $place => $value) { foreach ($split as $place => $value) {
if (substr_count($n, $place) != $value) { if (substr_count($n, $place) != $value) {
return false; return false;
} }
} }
return true; return true;
} }

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 public static function mersenne(int $p) : int
{ {
return 2**$p - 1; return 2 ** $p - 1;
} }
/** /**
@ -81,24 +81,24 @@ class Prime
if ($n < 2 || $n % 2 == 0) { if ($n < 2 || $n % 2 == 0) {
return false; return false;
} }
$d = $n - 1; $d = $n - 1;
$s = 0; $s = 0;
while ($d % 2 == 0) { while ($d % 2 == 0) {
$d /= 2; $d /= 2;
$s++; $s++;
} }
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;
} }
for ($j = 1; $j < $s; $j++) { for ($j = 1; $j < $s; $j++) {
$x = bcmod(bcmul($x, $x), $n); $x = bcmod(bcmul($x, $x), $n);
@ -120,10 +120,10 @@ class Prime
public static function sieveOfEratosthenes(int $n) : array public static function sieveOfEratosthenes(int $n) : array
{ {
$number = 2; $number = 2;
$range = range(2, $n); $range = range(2, $n);
$primes = array_combine($range, $range); $primes = array_combine($range, $range);
while ($number*$number < $n) { while ($number * $number < $n) {
for ($i = $number; $i <= $n; $i += $number) { for ($i = $number; $i <= $n; $i += $number) {
if ($i == $number) { if ($i == $number) {
continue; continue;
@ -141,11 +141,11 @@ class Prime
public function isPrime(int $n) : bool public function isPrime(int $n) : bool
{ {
$i = 2; $i = 2;
if ($n === 2) { if ($n === 2) {
return true; return true;
} }
$sqrtN = sqrt($n); $sqrtN = sqrt($n);
while ($i <= $sqrtN) { while ($i <= $sqrtN) {
if ($n % $i === 0) { if ($n % $i === 0) {
@ -154,7 +154,7 @@ class Prime
$i++; $i++;
} }
return true; return true;
} }
} }

View File

@ -1,39 +1,39 @@
<?php <?php
class GaussianElimination class GaussianElimination
{ {
private function swapRows(&$a, &$b, $r1, $r2) private function swapRows(&$a, &$b, $r1, $r2)
{ {
if ($r1 == $r2) { if ($r1 == $r2) {
return; return;
} }
$tmp = $a[$r1]; $tmp = $a[$r1];
$a[$r1] = $a[$r2]; $a[$r1] = $a[$r2];
$a[$r2] = $tmp; $a[$r2] = $tmp;
$tmp = $b[$r1]; $tmp = $b[$r1];
$b[$r1] = $b[$r2]; $b[$r1] = $b[$r2];
$b[$r2] = $tmp; $b[$r2] = $tmp;
} }
public function solve(array $A, array $b, int $limit) : array public function solve(array $A, array $b, int $limit) : array
{ {
for ($col = 0; $col < $limit; $col++) { for ($col = 0; $col < $limit; $col++) {
$j = $col; $j = $col;
$max = $A[$j][$j]; $max = $A[$j][$j];
for ($i = $col + 1; $i < $limit; $i++) { for ($i = $col + 1; $i < $limit; $i++) {
$tmp = abs($A[$i][$col]); $tmp = abs($A[$i][$col]);
if ($tmp > $max) { if ($tmp > $max) {
$j = $i; $j = $i;
$max = $tmp; $max = $tmp;
} }
} }
$this->swapRows($A, $b, $col, $j); $this->swapRows($A, $b, $col, $j);
for ($i = $col + 1; $i < $limit; $i++) { for ($i = $col + 1; $i < $limit; $i++) {
$tmp = $A[$i][$col] / $A[$col][$col]; $tmp = $A[$i][$col] / $A[$col][$col];

View File

@ -2,9 +2,11 @@
namespace phpOMS\Math\Optimization\Graph; namespace phpOMS\Math\Optimization\Graph;
class Dijkstra { class Dijkstra
public static function dijkstra(Graph $graph, $source, $target) { {
$vertices = []; public static function dijkstra(Graph $graph, $source, $target)
{
$vertices = [];
$neighbours = []; $neighbours = [];
foreach ($graph_array as $edge) { foreach ($graph_array as $edge) {
@ -14,41 +16,41 @@ class Dijkstra {
} }
$vertices = array_unique($vertices); $vertices = array_unique($vertices);
$dist = []; $dist = [];
$previous = []; $previous = [];
foreach ($vertices as $vertex) { foreach ($vertices as $vertex) {
$dist[$vertex] = INF; $dist[$vertex] = INF;
$previous[$vertex] = NULL; $previous[$vertex] = null;
} }
$dist[$source] = 0; $dist[$source] = 0;
$Q = $vertices; $Q = $vertices;
while (count($Q) > 0) { while (count($Q) > 0) {
// TODO - Find faster way to get minimum // TODO - Find faster way to get minimum
$min = INF; $min = INF;
foreach ($Q as $vertex){ foreach ($Q as $vertex) {
if ($dist[$vertex] < $min) { if ($dist[$vertex] < $min) {
$min = $dist[$vertex]; $min = $dist[$vertex];
$u = $vertex; $u = $vertex;
} }
} }
$Q = array_diff($Q, [$u]); $Q = array_diff($Q, [$u]);
if ($dist[$u] == INF || $u == $target) { if ($dist[$u] == INF || $u == $target) {
break; break;
} }
if (isset($neighbours[$u])) { if (isset($neighbours[$u])) {
foreach ($neighbours[$u] as $arr) { foreach ($neighbours[$u] as $arr) {
$alt = $dist[$u] + $arr["cost"]; $alt = $dist[$u] + $arr["cost"];
if ($alt < $dist[$arr["end"]]) { if ($alt < $dist[$arr["end"]]) {
$dist[$arr["end"]] = $alt; $dist[$arr["end"]] = $alt;
$previous[$arr["end"]] = $u; $previous[$arr["end"]] = $u;
} }
} }
@ -56,7 +58,7 @@ class Dijkstra {
} }
$path = []; $path = [];
$u = $target; $u = $target;
while (isset($previous[$u])) { while (isset($previous[$u])) {
array_unshift($path, $u); array_unshift($path, $u);

View File

@ -26,9 +26,9 @@ namespace phpOMS\Math\Optimization\Graph;
* @link http://orange-management.com * @link http://orange-management.com
* @since 1.0.0 * @since 1.0.0
*/ */
interface EdgeInterface interface EdgeInterface
{ {
/** /**
* Get edge id. * Get edge id.
* *
* @return mixed * @return mixed
@ -36,9 +36,9 @@ interface EdgeInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getId(); public function getId();
/** /**
* Get edge weight. * Get edge weight.
* *
* @return mixed * @return mixed
@ -46,9 +46,9 @@ interface EdgeInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getWeight(); public function getWeight();
/** /**
* Set weight. * Set weight.
* *
* @param mixed $weight Weight of edge * @param mixed $weight Weight of edge
@ -56,9 +56,9 @@ interface EdgeInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function setWeight($weight); public function setWeight($weight);
/** /**
* Get vertices. * Get vertices.
* *
* @return array * @return array
@ -66,9 +66,9 @@ interface EdgeInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getVertices() : array; public function getVertices() : array;
/** /**
* Set vertices. * Set vertices.
* *
* @param VerticeInterface $a Vertice a * @param VerticeInterface $a Vertice a
@ -77,5 +77,5 @@ interface EdgeInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function setVertices(VerticeInterface $a, VerticeInterface $b); public function setVertices(VerticeInterface $a, VerticeInterface $b);
} }

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com * @link http://orange-management.com
*/ */
namespace phpOMS\Math\Optimization\Graph; namespace phpOMS\Math\Optimization\Graph;
use phpOMS\Stdlib\Map\KeyType; use phpOMS\Stdlib\Map\KeyType;
use phpOMS\Stdlib\Map\MultiMap; use phpOMS\Stdlib\Map\MultiMap;
use phpOMS\Stdlib\Map\OrderType; use phpOMS\Stdlib\Map\OrderType;
@ -53,7 +54,7 @@ class Graph
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function __construct() public function __construct()
{ {
$this->edges = new MultiMap(KeyType::MULTIPLE, OrderType::LOOSE); $this->edges = new MultiMap(KeyType::MULTIPLE, OrderType::LOOSE);
} }
@ -89,7 +90,7 @@ class Graph
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
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;
@ -149,8 +150,8 @@ class Graph
*/ */
public function removeEdgeById($id) : bool public function removeEdgeById($id) : bool
{ {
if (isset($this->edge[$id])) { if (isset($this->edges[$id])) {
unset($this->edge[$id]); unset($this->edges[$id]);
return true; return true;
} }
@ -203,7 +204,7 @@ class Graph
*/ */
public function getEdgeById(int $id) : EdgeInterface public function getEdgeById(int $id) : EdgeInterface
{ {
return $this->edges->get([$a, $b]) ?? new NullEdge(); return $this->edges->get($id) ?? new NullEdge();
} }
/** /**
@ -214,7 +215,7 @@ class Graph
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function countVertices() : int public function countVertices() : int
{ {
return count($this->vertices); return count($this->vertices);
} }

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

@ -26,9 +26,9 @@ namespace phpOMS\Math\Optimization\Graph;
* @link http://orange-management.com * @link http://orange-management.com
* @since 1.0.0 * @since 1.0.0
*/ */
interface VerticeInterface interface VerticeInterface
{ {
/** /**
* Get vertice id. * Get vertice id.
* *
* @return mixed * @return mixed
@ -36,9 +36,9 @@ interface VerticeInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getId(); public function getId();
/** /**
* Get edges. * Get edges.
* *
* @return array * @return array
@ -46,9 +46,9 @@ interface VerticeInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getEdges() : array; public function getEdges() : array;
/** /**
* Add edge. * Add edge.
* *
* @param EdgeInterface $edge Edge to add to vertice * @param EdgeInterface $edge Edge to add to vertice
@ -58,5 +58,5 @@ interface VerticeInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function addEdge(EdgeInterface $edge) : bool; public function addEdge(EdgeInterface $edge) : bool;
} }

View File

@ -131,8 +131,8 @@ class Tour implements \Countable
/** /**
* Set city * Set city
* *
* @param int $index Index to set/replace * @param int $index Index to set/replace
* @param City $city City * @param City $city City
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>

View File

@ -16,7 +16,6 @@
namespace phpOMS\Math\Shape\D2; namespace phpOMS\Math\Shape\D2;
/** /**
* Polygon class. * Polygon class.
* *
@ -133,7 +132,7 @@ class Polygon implements ShapeInterface
/** /**
* Set polygon coordinate. * Set polygon coordinate.
* *
* @param int $i Index * @param int $i Index
* @param int|float $x X coordinate * @param int|float $x X coordinate
* @param int|float $y Y coordinate * @param int|float $y Y coordinate
* *

View File

@ -116,7 +116,7 @@ class Average
* Example: ([1, 2, 2, 3, 4, 4, 2]) * Example: ([1, 2, 2, 3, 4, 4, 2])
* *
* @param array $values Values * @param array $values Values
* @param int $offset Offset for outlier * @param int $offset Offset for outlier
* *
* @return float * @return float
* *
@ -148,7 +148,7 @@ class Average
* Example: ([1, 2, 2, 3, 4, 4, 2]) * Example: ([1, 2, 2, 3, 4, 4, 2])
* *
* @param array $values Values * @param array $values Values
* @param int $offset Offset for outlier * @param int $offset Offset for outlier
* *
* @return float * @return float
* *
@ -180,7 +180,7 @@ class Average
* Example: ([1, 2, 2, 3, 4, 4, 2]) * Example: ([1, 2, 2, 3, 4, 4, 2])
* *
* @param array $values Values * @param array $values Values
* @param int $offset Offset for outlier * @param int $offset Offset for outlier
* *
* @return float * @return float
* *
@ -217,7 +217,7 @@ class Average
* Example: ([1, 2, 2, 3, 4, 4, 2]) * Example: ([1, 2, 2, 3, 4, 4, 2])
* *
* @param array $angles Angles * @param array $angles Angles
* @param int $offset Offset for outlier * @param int $offset Offset for outlier
* *
* @return float * @return float
* *
@ -290,8 +290,8 @@ class Average
*/ */
public static function angleToTime(float $angle) : string public static function angleToTime(float $angle) : string
{ {
$sec = 86400.0 * $angle / 360.0; $sec = 86400.0 * $angle / 360.0;
$time = sprintf('%02d:%02d:%02d', floor($sec / 3600), floor(($sec % 3600) / 60), $sec % 60); $time = sprintf('%02d:%02d:%02d', floor($sec / 3600), floor(($sec % 3600) / 60), $sec % 60);
return $time; return $time;
} }
@ -302,7 +302,7 @@ class Average
* Example: ([1, 2, 2, 3, 4, 4, 2]) * Example: ([1, 2, 2, 3, 4, 4, 2])
* *
* @param array $angles Angles * @param array $angles Angles
* @param int $offset Offset for outlier * @param int $offset Offset for outlier
* *
* @return float * @return float
* *

View File

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

View File

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

View File

@ -151,7 +151,7 @@ class GeometricDistribution
*/ */
public static function getSkewness(float $lambda) : float 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 public static function getExKurtosis(float $lambda) : float
{ {
return 6 + $p ** 2 / (1 - $p); return 6 + $lambda ** 2 / (1 - $lambda);
} }
public static function getRandom() public static function getRandom()

View File

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

View File

@ -34,7 +34,7 @@ class UniformDistributionDiscrete
* Get probability mass function. * Get probability mass function.
* *
* @param float $a * @param float $a
* @param float $b * @param float $b
* *
* @return float * @return float
* *

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com * @link http://orange-management.com
*/ */
namespace phpOMS\Message; namespace phpOMS\Message;
use phpOMS\DataStorage\Cookie\CookieJar; use phpOMS\DataStorage\Cookie\CookieJar;
use phpOMS\DataStorage\Session\HttpSession; use phpOMS\DataStorage\Session\HttpSession;
@ -41,9 +42,9 @@ abstract class HeaderAbstract
/** /**
* Set header. * Set header.
* *
* @param string $key Header key * @param string $key Header key
* @param string $value Header value * @param string $value Header value
* @param bool $overwrite Overwrite if key already exists * @param bool $overwrite Overwrite if key already exists
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>

View File

@ -32,15 +32,15 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class BrowserType extends Enum abstract class BrowserType extends Enum
{ {
const IE = 'msie'; /* Internet Explorer */ const IE = 'msie'; /* Internet Explorer */
const EDGE = 'edge'; /* Internet Explorer Edge 20+ */ const EDGE = 'edge'; /* Internet Explorer Edge 20+ */
const FIREFOX = 'firefox'; /* Firefox */ const FIREFOX = 'firefox'; /* Firefox */
const SAFARI = 'safari'; /* Safari */ const SAFARI = 'safari'; /* Safari */
const CHROME = 'chrome'; /* Chrome */ const CHROME = 'chrome'; /* Chrome */
const OPERA = 'opera'; /* Opera */ const OPERA = 'opera'; /* Opera */
const NETSCAPE = 'netscape'; /* Netscape */ const NETSCAPE = 'netscape'; /* Netscape */
const MAXTHON = 'maxthon'; /* Maxthon */ const MAXTHON = 'maxthon'; /* Maxthon */
const KONQUEROR = 'konqueror'; /* Konqueror */ const KONQUEROR = 'konqueror'; /* Konqueror */
const HANDHELD = 'mobile'; /* Handheld Browser */ const HANDHELD = 'mobile'; /* Handheld Browser */
const BLINK = 'blink'; /* Blink Browser */ const BLINK = 'blink'; /* Blink Browser */
} }

View File

@ -88,7 +88,7 @@ class Header extends HeaderAbstract
if (self::$isLocked) { if (self::$isLocked) {
throw new \Exception('Already locked'); throw new \Exception('Already locked');
} }
if (isset($this->header[$key])) { if (isset($this->header[$key])) {
unset($this->header[$key]); unset($this->header[$key]);
@ -164,7 +164,7 @@ class Header extends HeaderAbstract
*/ */
public function generate(string $code) public function generate(string $code)
{ {
switch($code) { switch ($code) {
case RequestStatus::R_403: case RequestStatus::R_403:
$this->generate403(); $this->generate403();
break; break;
@ -204,7 +204,7 @@ class Header extends HeaderAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
private function generate406() private function generate406()
{ {
$this->set('HTTP', 'HTTP/1.0 406 Not acceptable'); $this->set('HTTP', 'HTTP/1.0 406 Not acceptable');
$this->set('Status', 'Status: 406 Not acceptable'); $this->set('Status', 'Status: 406 Not acceptable');
@ -233,7 +233,7 @@ class Header extends HeaderAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
private function generate407() private function generate407()
{ {
} }

View File

@ -32,27 +32,27 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class OSType extends Enum abstract class OSType extends Enum
{ {
const WINDOWS_81 = 'windows nt 6.3'; /* Windows 8.1 */ const WINDOWS_81 = 'windows nt 6.3'; /* Windows 8.1 */
const WINDOWS_8 = 'windows nt 6.2'; /* Windows 8 */ const WINDOWS_8 = 'windows nt 6.2'; /* Windows 8 */
const WINDOWS_7 = 'windows nt 6.1'; /* Windows 7 */ const WINDOWS_7 = 'windows nt 6.1'; /* Windows 7 */
const WINDOWS_VISTA = 'windows nt 6.0'; /* Windows Vista */ const WINDOWS_VISTA = 'windows nt 6.0'; /* Windows Vista */
const WINDOWS_SERVER = 'windows nt 5.2'; /* Windows Server 2003/XP x64 */ const WINDOWS_SERVER = 'windows nt 5.2'; /* Windows Server 2003/XP x64 */
const WINDOWS_XP = 'windows nt 5.1'; /* Windows XP */ const WINDOWS_XP = 'windows nt 5.1'; /* Windows XP */
const WINDOWS_XP_2 = 'windows xp'; /* Windows XP */ const WINDOWS_XP_2 = 'windows xp'; /* Windows XP */
const WINDOWS_2000 = 'windows nt 5.0'; /* Windows 2000 */ const WINDOWS_2000 = 'windows nt 5.0'; /* Windows 2000 */
const WINDOWS_ME = 'windows me'; /* Windows ME */ const WINDOWS_ME = 'windows me'; /* Windows ME */
const WINDOWS_98 = 'win98'; /* Windows 98 */ const WINDOWS_98 = 'win98'; /* Windows 98 */
const WINDOWS_95 = 'win95'; /* Windows 95 */ const WINDOWS_95 = 'win95'; /* Windows 95 */
const WINDOWS_311 = 'win16'; /* Windows 3.11 */ const WINDOWS_311 = 'win16'; /* Windows 3.11 */
const MAC_OS_X = 'macintosh'; /* Mac OS X */ const MAC_OS_X = 'macintosh'; /* Mac OS X */
const MAC_OS_X_2 = 'mac os x'; /* Mac OS X */ const MAC_OS_X_2 = 'mac os x'; /* Mac OS X */
const MAC_OS_9 = 'mac_powerpc'; /* Mac OS 9 */ const MAC_OS_9 = 'mac_powerpc'; /* Mac OS 9 */
const LINUX = 'linux'; /* Linux */ const LINUX = 'linux'; /* Linux */
const UBUNTU = 'ubuntu'; /* Ubuntu */ const UBUNTU = 'ubuntu'; /* Ubuntu */
const IPHONE = 'iphone'; /* IPhone */ const IPHONE = 'iphone'; /* IPhone */
const IPOD = 'ipod'; /* IPod */ const IPOD = 'ipod'; /* IPod */
const IPAD = 'ipad'; /* IPad */ const IPAD = 'ipad'; /* IPad */
const ANDROID = 'android'; /* Android */ const ANDROID = 'android'; /* Android */
const BLACKBERRY = 'blackberry'; /* Blackberry */ const BLACKBERRY = 'blackberry'; /* Blackberry */
const MOBILE = 'webos'; /* Mobile */ const MOBILE = 'webos'; /* Mobile */
} }

View File

@ -126,7 +126,7 @@ class Request extends RequestAbstract
$this->path = explode('/', $this->uri->getPath()); $this->path = explode('/', $this->uri->getPath());
$this->l11n->setLanguage($this->path[0]); $this->l11n->setLanguage($this->path[0]);
$this->setupUriBuilder(); $this->setupUriBuilder();
$this->createRequestHashs(); $this->createRequestHashs();
} }
@ -141,9 +141,9 @@ class Request extends RequestAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
private function initCurrentRequest() private function initCurrentRequest()
{ {
$this->data = $_GET ?? []; $this->data = $_GET ?? [];
$this->files = $_FILES ?? []; $this->files = $_FILES ?? [];
if (isset($_SERVER['CONTENT_TYPE'])) { if (isset($_SERVER['CONTENT_TYPE'])) {
@ -222,7 +222,7 @@ class Request extends RequestAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
private function cleanupGlobals() private function cleanupGlobals()
{ {
unset($_FILES); unset($_FILES);
unset($_GET); unset($_GET);
@ -364,10 +364,10 @@ class Request extends RequestAbstract
} }
return return
(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
|| (empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') || (empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
|| (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') || (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
|| $_SERVER['SERVER_PORT'] == $port; || $_SERVER['SERVER_PORT'] == $port;
} }
/** /**
@ -409,7 +409,7 @@ class Request extends RequestAbstract
public function getProtocolVersion() : string public function getProtocolVersion() : string
{ {
return $_SERVER['SERVER_PROTOCOL']; return $_SERVER['SERVER_PROTOCOL'];
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -452,7 +452,7 @@ class Request extends RequestAbstract
*/ */
public function getRouteVerb() : int public function getRouteVerb() : int
{ {
switch($this->getMethod()) { switch ($this->getMethod()) {
case RequestMethod::GET: case RequestMethod::GET:
return RouteVerb::GET; return RouteVerb::GET;
case RequestMethod::PUT: case RequestMethod::PUT:

View File

@ -30,10 +30,10 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class RequestMethod extends Enum abstract class RequestMethod extends Enum
{ {
const GET = 'GET'; /* GET */ const GET = 'GET'; /* GET */
const POST = 'POST'; /* POST */ const POST = 'POST'; /* POST */
const PUT = 'PUT'; /* PUT */ const PUT = 'PUT'; /* PUT */
const DELETE = 'DELETE'; /* DELETE */ const DELETE = 'DELETE'; /* DELETE */
const HEAD = 'HEAD'; /* HEAD */ const HEAD = 'HEAD'; /* HEAD */
const TRACE = 'TRACE'; /* TRACE */ const TRACE = 'TRACE'; /* TRACE */
} }

View File

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

View File

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

View File

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

View File

@ -30,9 +30,9 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class MailType extends Enum abstract class MailType extends Enum
{ {
const MAIL = 0; const MAIL = 0;
const SMTP = 1; const SMTP = 1;
const IMAP = 2; const IMAP = 2;
const POP3 = 3; const POP3 = 3;
const SENDMAIL = 4; const SENDMAIL = 4;
} }

View File

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

View File

@ -30,7 +30,7 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class RequestSource extends Enum abstract class RequestSource extends Enum
{ {
const WEB = 0; /* This is a http request */ const WEB = 0; /* This is a http request */
const CONSOLE = 1; /* Request is a console command */ const CONSOLE = 1; /* Request is a console command */
const SOCKET = 2; /* Request through socket connection */ const SOCKET = 2; /* Request through socket connection */
} }

View File

@ -108,7 +108,7 @@ abstract class ResponseAbstract implements MessageInterface
* *
* @param mixed $key Response id * @param mixed $key Response id
* @param mixed $response Response to add * @param mixed $response Response to add
* @param bool $overwrite Overwrite * @param bool $overwrite Overwrite
* *
* @return void * @return void
* *

View File

@ -30,8 +30,8 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class ResponseType extends Enum abstract class ResponseType extends Enum
{ {
const HTTP = 0; /* HTTP */ const HTTP = 0; /* HTTP */
const JSON = 1; /* JSON */ const JSON = 1; /* JSON */
const SOCKET = 2; /* Socket */ const SOCKET = 2; /* Socket */
const CONSOLE = 3; /* Console */ const CONSOLE = 3; /* Console */
} }

View File

@ -219,9 +219,9 @@ class Meta implements RenderableInterface
public function render() : string public function render() : string
{ {
return (count($this->keywords) > 0 ? '<meta name="keywords" content="' . implode(',', $this->keywords) . '">"' : '') return (count($this->keywords) > 0 ? '<meta name="keywords" content="' . implode(',', $this->keywords) . '">"' : '')
. (isset($this->author) ? '<meta name="author" content="' . $this->author . '">' : '') . (isset($this->author) ? '<meta name="author" content="' . $this->author . '">' : '')
. (isset($this->description) ? '<meta name="description" content="' . $this->description . '">' : '') . (isset($this->description) ? '<meta name="description" content="' . $this->description . '">' : '')
. (isset($this->charset) ? '<meta charset="' . $this->charset . '">' : '') . (isset($this->charset) ? '<meta charset="' . $this->charset . '">' : '')
. '<meta name="generator" content="Orange Management">'; . '<meta name="generator" content="Orange Management">';
} }
} }

View File

@ -34,7 +34,7 @@ class ActivateAbstract
/** /**
* Install module. * Install module.
* *
* @param Pool $dbPool Database instance * @param Pool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void

View File

@ -34,7 +34,7 @@ class DeactivateAbstract
/** /**
* Install module. * Install module.
* *
* @param Pool $dbPool Database instance * @param Pool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void

View File

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

View File

@ -35,7 +35,7 @@ class InstallerAbstract
/** /**
* Install module. * Install module.
* *
* @param Pool $dbPool Database instance * @param Pool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void
@ -53,8 +53,8 @@ class InstallerAbstract
/** /**
* Install routes. * Install routes.
* *
* @param string $destRoutePath Destination route path * @param string $destRoutePath Destination route path
* @param string $srcRoutePath Source route path * @param string $srcRoutePath Source route path
* *
* @return void * @return void
* *
@ -63,9 +63,9 @@ class InstallerAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
private static function installRoutes(string $destRoutePath, string $srcRoutePath) private static function installRoutes(string $destRoutePath, string $srcRoutePath)
{ {
if(file_exists($destRoutePath) && file_exists($srcRoutePath)) { if (file_exists($destRoutePath) && file_exists($srcRoutePath)) {
/** @noinspection PhpIncludeInspection */ /** @noinspection PhpIncludeInspection */
$appRoutes = include $destRoutePath; $appRoutes = include $destRoutePath;
/** @noinspection PhpIncludeInspection */ /** @noinspection PhpIncludeInspection */
@ -73,7 +73,7 @@ class InstallerAbstract
$appRoutes = array_merge_recursive($appRoutes, $moduleRoutes); $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); file_put_contents($destRoutePath, '<?php return ' . ArrayParser::serializeArray($appRoutes) . ';', LOCK_EX);
} else { } else {
throw new PermissionException($destRoutePath); throw new PermissionException($destRoutePath);

View File

@ -64,7 +64,7 @@ class ModuleFactory
/** /**
* Gets and initializes modules. * Gets and initializes modules.
* *
* @param string $module Module ID * @param string $module Module ID
* @param ApplicationAbstract $app Application * @param ApplicationAbstract $app Application
* *
* @return ModuleAbstract * @return ModuleAbstract
@ -76,7 +76,7 @@ class ModuleFactory
{ {
if (!isset(self::$loaded[$module])) { if (!isset(self::$loaded[$module])) {
try { try {
$class = '\\Modules\\' . $module . '\\Controller'; $class = '\\Modules\\' . $module . '\\Controller';
$obj = new $class($app); $obj = new $class($app);
self::$loaded[$module] = $obj; self::$loaded[$module] = $obj;
self::registerRequesting($obj); self::registerRequesting($obj);
@ -118,11 +118,11 @@ class ModuleFactory
*/ */
private static function registerProvided(ModuleAbstract $obj) private static function registerProvided(ModuleAbstract $obj)
{ {
$name = $obj->getName(); $name = $obj->getName();
if (isset(self::$providing[$name])) { if (isset(self::$providing[$name])) {
foreach (self::$providing[$name] as $providing) { foreach (self::$providing[$name] as $providing) {
self::$loaded[$name]->addReceiving($providing); self::$loaded[$name]->addReceiving($providing);
}
} }
} }
} }
}

View File

@ -146,21 +146,21 @@ class ModuleManager
if (!isset($this->uriLoad)) { if (!isset($this->uriLoad)) {
switch ($this->app->dbPool->get('core')->getType()) { switch ($this->app->dbPool->get('core')->getType()) {
case DatabaseType::MYSQL: case DatabaseType::MYSQL:
$uriHash = $request->getHash(); $uriHash = $request->getHash();
$uriPdo = ''; $uriPdo = '';
$i = 1; $i = 1;
$c = count($uriHash); $c = count($uriHash);
for ($k = 0; $k < $c; $k++) { for ($k = 0; $k < $c; $k++) {
$uriPdo .= ':pid' . $i . ','; $uriPdo .= ':pid' . $i . ',';
$i++; $i++;
} }
$uriPdo = rtrim($uriPdo, ','); $uriPdo = rtrim($uriPdo, ',');
/* TODO: make join in order to see if they are active */ /* TODO: make join in order to see if they are active */
$sth = $this->app->dbPool->get('core')->con->prepare( $sth = $this->app->dbPool->get('core')->con->prepare(
'SELECT 'SELECT
`' . $this->app->dbPool->get('core')->prefix . 'module_load`.`module_load_type`, `' . $this->app->dbPool->get('core')->prefix . 'module_load`.* `' . $this->app->dbPool->get('core')->prefix . 'module_load`.`module_load_type`, `' . $this->app->dbPool->get('core')->prefix . 'module_load`.*
FROM FROM
`' . $this->app->dbPool->get('core')->prefix . 'module_load` `' . $this->app->dbPool->get('core')->prefix . 'module_load`
@ -168,15 +168,15 @@ class ModuleManager
`module_load_pid` IN(' . $uriPdo . ')' `module_load_pid` IN(' . $uriPdo . ')'
); );
$i = 1; $i = 1;
foreach ($uriHash as $hash) { foreach ($uriHash as $hash) {
$sth->bindValue(':pid' . $i, $hash, \PDO::PARAM_STR); $sth->bindValue(':pid' . $i, $hash, \PDO::PARAM_STR);
$i++; $i++;
} }
$sth->execute(); $sth->execute();
$this->uriLoad = $sth->fetchAll(\PDO::FETCH_GROUP); $this->uriLoad = $sth->fetchAll(\PDO::FETCH_GROUP);
} }
} }
@ -314,10 +314,10 @@ class ModuleManager
foreach ($installed as $key => $value) { foreach ($installed as $key => $value) {
$this->installProviding($key, $module); $this->installProviding($key, $module);
} }
} catch(PathException $e) { } catch (PathException $e) {
// todo: handle module doesn't exist or files are missing // todo: handle module doesn't exist or files are missing
//echo $e->getMessage(); //echo $e->getMessage();
} catch(\Exception $e) { } catch (\Exception $e) {
//echo $e->getMessage(); //echo $e->getMessage();
} }
} }
@ -336,42 +336,42 @@ class ModuleManager
{ {
switch ($this->app->dbPool->get('core')->getType()) { switch ($this->app->dbPool->get('core')->getType()) {
case DatabaseType::MYSQL: case DatabaseType::MYSQL:
$this->app->dbPool->get('core')->con->beginTransaction(); $this->app->dbPool->get('core')->con->beginTransaction();
$sth = $this->app->dbPool->get('core')->con->prepare( $sth = $this->app->dbPool->get('core')->con->prepare(
'INSERT INTO `' . $this->app->dbPool->get('core')->prefix . 'module` (`module_id`, `module_theme`, `module_path`, `module_active`, `module_version`) VALUES 'INSERT INTO `' . $this->app->dbPool->get('core')->prefix . 'module` (`module_id`, `module_theme`, `module_path`, `module_active`, `module_version`) VALUES
(:internal, :theme, :path, :active, :version);' (:internal, :theme, :path, :active, :version);'
); );
$sth->bindValue(':internal', $info->getInternalName(), \PDO::PARAM_INT); $sth->bindValue(':internal', $info->getInternalName(), \PDO::PARAM_INT);
$sth->bindValue(':theme', 'Default', \PDO::PARAM_STR); $sth->bindValue(':theme', 'Default', \PDO::PARAM_STR);
$sth->bindValue(':path', $info->getDirectory(), \PDO::PARAM_STR); $sth->bindValue(':path', $info->getDirectory(), \PDO::PARAM_STR);
$sth->bindValue(':active', 1, \PDO::PARAM_INT); $sth->bindValue(':active', 1, \PDO::PARAM_INT);
$sth->bindValue(':version', $info->getVersion(), \PDO::PARAM_STR); $sth->bindValue(':version', $info->getVersion(), \PDO::PARAM_STR);
$sth->execute(); $sth->execute();
$sth = $this->app->dbPool->get('core')->con->prepare( $sth = $this->app->dbPool->get('core')->con->prepare(
'INSERT INTO `' . $this->app->dbPool->get('core')->prefix . 'module_load` (`module_load_pid`, `module_load_type`, `module_load_from`, `module_load_for`, `module_load_file`) VALUES 'INSERT INTO `' . $this->app->dbPool->get('core')->prefix . 'module_load` (`module_load_pid`, `module_load_type`, `module_load_from`, `module_load_for`, `module_load_file`) VALUES
(:pid, :type, :from, :for, :file);' (:pid, :type, :from, :for, :file);'
); );
$load = $info->getLoad(); $load = $info->getLoad();
foreach ($load as $val) { foreach ($load as $val) {
foreach ($val['pid'] as $pid) { foreach ($val['pid'] as $pid) {
$sth->bindValue(':pid', $pid, \PDO::PARAM_STR); $sth->bindValue(':pid', $pid, \PDO::PARAM_STR);
$sth->bindValue(':type', $val['type'], \PDO::PARAM_INT); $sth->bindValue(':type', $val['type'], \PDO::PARAM_INT);
$sth->bindValue(':from', $val['from'], \PDO::PARAM_STR); $sth->bindValue(':from', $val['from'], \PDO::PARAM_STR);
$sth->bindValue(':for', $val['for'], \PDO::PARAM_STR); $sth->bindValue(':for', $val['for'], \PDO::PARAM_STR);
$sth->bindValue(':file', $val['file'], \PDO::PARAM_STR); $sth->bindValue(':file', $val['file'], \PDO::PARAM_STR);
$sth->execute(); $sth->execute();
}
} }
}
$this->app->dbPool->get('core')->con->commit(); $this->app->dbPool->get('core')->con->commit();
break; break;
} }
} }
@ -408,7 +408,7 @@ class ModuleManager
{ {
$class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer'; $class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer';
if(!Autoloader::exists($class)) { if (!Autoloader::exists($class)) {
throw new \Exception('Module installer does not exist'); throw new \Exception('Module installer does not exist');
} }
@ -453,10 +453,10 @@ class ModuleManager
if ($this->installed === null) { if ($this->installed === null) {
switch ($this->app->dbPool->get('core')->getType()) { switch ($this->app->dbPool->get('core')->getType()) {
case DatabaseType::MYSQL: case DatabaseType::MYSQL:
$sth = $this->app->dbPool->get('core')->con->prepare('SELECT `module_id`,`module_theme`,`module_version`,`module_id` FROM `' . $this->app->dbPool->get('core')->prefix . 'module`'); $sth = $this->app->dbPool->get('core')->con->prepare('SELECT `module_id`,`module_theme`,`module_version`,`module_id` FROM `' . $this->app->dbPool->get('core')->prefix . 'module`');
$sth->execute(); $sth->execute();
$this->installed = $sth->fetchAll(\PDO::FETCH_GROUP); $this->installed = $sth->fetchAll(\PDO::FETCH_GROUP);
break; break;
} }
} }
@ -526,7 +526,7 @@ class ModuleManager
'message' => 'Trying to initialize ' . $module . ' without controller.', 'message' => 'Trying to initialize ' . $module . ' without controller.',
'line' => $e->getLine(), 'line' => $e->getLine(),
'file' => $e->getFile(), 'file' => $e->getFile(),
]); ]);
} }
} }
} }
@ -543,7 +543,7 @@ class ModuleManager
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn * @author Dennis Eichhorn
*/ */
private function initModuleController(string $module) private function initModuleController(string $module)
{ {
$this->running[$module] = ModuleFactory::getInstance($module, $this->app); $this->running[$module] = ModuleFactory::getInstance($module, $this->app);
$this->app->dispatcher->set($this->running[$module], '\Modules\\' . $module . '\\Controller'); $this->app->dispatcher->set($this->running[$module], '\Modules\\' . $module . '\\Controller');

View File

@ -34,7 +34,7 @@ class UninstallAbstract
/** /**
* Install module. * Install module.
* *
* @param Pool $dbPool Database instance * @param Pool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void

View File

@ -34,7 +34,7 @@ class UpdateAbstract
/** /**
* Install module. * Install module.
* *
* @param Pool $dbPool Database instance * @param Pool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void

View File

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

View File

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

View File

@ -31,10 +31,10 @@ use phpOMS\Socket\SocketAbstract;
*/ */
class ClientConnection class ClientConnection
{ {
private $id = 0; private $id = 0;
private $socket = null; private $socket = null;
private $handshake = false; private $handshake = false;
private $pid = null; private $pid = null;
private $connected = true; private $connected = true;
public function __construct($id, $socket) public function __construct($id, $socket)
@ -48,35 +48,43 @@ class ClientConnection
return $this->id; return $this->id;
} }
public function getSocket() { public function getSocket()
{
return $this->socket; return $this->socket;
} }
public function getHandshake() { public function getHandshake()
{
return $this->handshake; return $this->handshake;
} }
public function getPid() { public function getPid()
{
return $this->pid; return $this->pid;
} }
public function isConnected() { public function isConnected()
{
return $this->connected; return $this->connected;
} }
public function setSocket($socket) { public function setSocket($socket)
{
$this->socket = $socket; $this->socket = $socket;
} }
public function setHandshake($handshake) { public function setHandshake($handshake)
{
$this->handshake = $handshake; $this->handshake = $handshake;
} }
public function setPid($pid) { public function setPid($pid)
{
$this->pid = $pid; $this->pid = $pid;
} }
public function setConnected(bool $connected) { public function setConnected(bool $connected)
{
$this->connected = $connected; $this->connected = $connected;
} }
} }

View File

@ -57,8 +57,8 @@ class CommandManager implements \Countable
* Attach new command. * Attach new command.
* *
* @param string $cmd Command ID * @param string $cmd Command ID
* @param mixed $callback Function callback * @param mixed $callback Function callback
* @param mixed $source Provider * @param mixed $source Provider
* *
* @return void * @return void
* *
@ -75,7 +75,7 @@ class CommandManager implements \Countable
* Detach existing command. * Detach existing command.
* *
* @param string $cmd Command ID * @param string $cmd Command ID
* @param mixed $source Provider * @param mixed $source Provider
* *
* @return void * @return void
* *
@ -94,8 +94,8 @@ class CommandManager implements \Countable
* Trigger command. * Trigger command.
* *
* @param string $cmd Command ID * @param string $cmd Command ID
* @param mixed $conn Client ID * @param mixed $conn Client ID
* @param mixed $para Parameters to pass * @param mixed $para Parameters to pass
* *
* @return mixed|bool * @return mixed|bool
* *

View File

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

View File

@ -30,15 +30,15 @@ use phpOMS\Datatypes\Enum;
*/ */
abstract class PacketType extends Enum abstract class PacketType extends Enum
{ {
const CONNECT = 0; /* Client connection (server/sender) */ const CONNECT = 0; /* Client connection (server/sender) */
const DISCONNECT = 1; /* Client disconnection (server/sender) */ const DISCONNECT = 1; /* Client disconnection (server/sender) */
const KICK = 2; /* Kick (server/client/sender) */ const KICK = 2; /* Kick (server/client/sender) */
const PING = 3; /* Ping (server/sender) */ const PING = 3; /* Ping (server/sender) */
const HELP = 4; /* Help (server/sender) */ const HELP = 4; /* Help (server/sender) */
const RESTART = 5; /* Restart server (server/all clients/client) */ const RESTART = 5; /* Restart server (server/all clients/client) */
const MSG = 6; /* Message (server/sender/client/all clients?) */ const MSG = 6; /* Message (server/sender/client/all clients?) */
const LOGIN = 7; /* Login (server/sender) */ const LOGIN = 7; /* Login (server/sender) */
const LOGOUT = 8; /* Logout (server/sender) */ const LOGOUT = 8; /* Logout (server/sender) */
const ACCMODIFY = 9; /* Account modification (server/sender (admin)/user) */ const ACCMODIFY = 9; /* Account modification (server/sender (admin)/user) */
const MODULE = 999999999; /* Module packet ??? */ const MODULE = 999999999; /* Module packet ??? */
} }

View File

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

View File

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

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com * @link http://orange-management.com
*/ */
namespace phpOMS\Stdlib\Map; namespace phpOMS\Stdlib\Map;
use phpOMS\Utils\Permutation; use phpOMS\Utils\Permutation;
/** /**
@ -65,7 +66,7 @@ class MultiMap implements \Countable
/** /**
* Constructor. * Constructor.
* *
* @param int $key Key type (all keys need to match or just one) * @param int $key Key type (all keys need to match or just one)
* @param int $order Order of the keys is important (only required for multiple keys) * @param int $order Order of the keys is important (only required for multiple keys)
* *
* @since 1.0.0 * @since 1.0.0
@ -73,7 +74,7 @@ class MultiMap implements \Countable
*/ */
public function __construct(int $key = KeyType::SINGLE, int $order = OrderType::LOOSE) public function __construct(int $key = KeyType::SINGLE, int $order = OrderType::LOOSE)
{ {
$this->keyType = $key; $this->keyType = $key;
$this->orderType = $order; $this->orderType = $order;
} }
@ -82,7 +83,7 @@ class MultiMap implements \Countable
* *
* @param array $keys Keys for value * @param array $keys Keys for value
* @param mixed $value Value to store * @param mixed $value Value to store
* @param bool $overwrite Add value if key exists * @param bool $overwrite Add value if key exists
* *
* @return bool * @return bool
* *
@ -169,7 +170,7 @@ class MultiMap implements \Countable
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn * @author Dennis Eichhorn
*/ */
private function getSingle($key) private function getSingle($key)
{ {
return isset($this->keys[$key]) ? $this->values[$this->keys[$key]] ?? null : null; return isset($this->keys[$key]) ? $this->values[$this->keys[$key]] ?? null : null;
} }
@ -184,7 +185,7 @@ class MultiMap implements \Countable
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn * @author Dennis Eichhorn
*/ */
private function getMultiple($key) private function getMultiple($key)
{ {
if (is_array($key)) { if (is_array($key)) {
if ($this->orderType === OrderType::LOOSE) { if ($this->orderType === OrderType::LOOSE) {
@ -409,7 +410,7 @@ class MultiMap implements \Countable
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn * @author Dennis Eichhorn
*/ */
private function removeKeySingle($key) : bool private function removeKeySingle($key) : bool
{ {
if (isset($this->keys[$key])) { if (isset($this->keys[$key])) {
unset($this->keys[$key]); unset($this->keys[$key]);

View File

@ -58,7 +58,7 @@ class PriorityQueue implements \Countable, \Serializable
/** /**
* Insert element into queue. * Insert element into queue.
* *
* @param mixed $data Queue element * @param mixed $data Queue element
* @param float $priority Priority of this element * @param float $priority Priority of this element
* *
* @return int * @return int
@ -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 public function unserialize($data) : array
{ {

View File

@ -51,8 +51,8 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
* *
* This can become rather slow for large structures. * This can become rather slow for large structures.
* *
* @param string $dir Root dir to inspect * @param string $dir Root dir to inspect
* @param bool $recursive Get size recursive * @param bool $recursive Get size recursive
* *
* @return int * @return int
* *
@ -71,9 +71,11 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
if ($filename != ".." && $filename != ".") { if ($filename != ".." && $filename != ".") {
if (is_dir($dir . "/" . $filename) && $recursive) { if (is_dir($dir . "/" . $filename) && $recursive) {
$countSize += self::getFolderSize($dir . "/" . $filename, $recursive); $countSize += self::getFolderSize($dir . "/" . $filename, $recursive);
} else if (is_file($dir . "/" . $filename)) { } else {
$countSize += filesize($dir . "/" . $filename); if (is_file($dir . "/" . $filename)) {
$count++; $countSize += filesize($dir . "/" . $filename);
$count++;
}
} }
} }
} }
@ -155,9 +157,9 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
/** /**
* Create directory. * Create directory.
* *
* @param string $path Path * @param string $path Path
* @param int $permission Directory permission * @param int $permission Directory permission
* @param bool $recursive Create parent directories if applicable * @param bool $recursive Create parent directories if applicable
* *
* @return bool * @return bool
* *
@ -204,19 +206,19 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
/** /**
* Constructor. * Constructor.
* *
* @param string $path Path * @param string $path Path
* @param string $filter Filter * @param string $filter Filter
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function __construct(string $path, string $filter = '*') public function __construct(string $path, string $filter = '*')
{ {
$this->filter = $filter; $this->filter = $filter;
parent::__construct($path); parent::__construct($path);
if (file_exists($this->path)) { if (file_exists($this->path)) {
parent::index(); $this->index();
} }
} }
@ -230,7 +232,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function get(string $name) : FileAbstract public function get(string $name) : FileAbstract
{ {
return $this->nodes[$name] ?? new NullFile(''); return $this->nodes[$name] ?? new NullFile('');
} }
@ -287,6 +289,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
$this->size -= $this->nodes[$name]->getSize(); $this->size -= $this->nodes[$name]->getSize();
unset($this->nodes[$name]); unset($this->nodes[$name]);
// todo: unlink??? // todo: unlink???
return true; return true;
@ -303,7 +306,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function index() public function index()
{ {
parent::index(); parent::index();
@ -340,7 +343,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function key() public function key()
{ {
return key($this->nodes); return key($this->nodes);
} }
@ -348,7 +351,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function next() public function next()
{ {
return next($this->nodes); return next($this->nodes);
} }
@ -367,7 +370,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
if (is_null($offset)) { if (is_null($offset)) {
$this->add($value); $this->add($value);
@ -379,7 +382,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function offsetExists($offset) public function offsetExists($offset)
{ {
return isset($this->nodes[$offset]); return isset($this->nodes[$offset]);
} }
@ -387,7 +390,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
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]);
@ -397,7 +400,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function offsetGet($offset) public function offsetGet($offset)
{ {
return $this->nodes[$offset] ?? null; return $this->nodes[$offset] ?? null;
} }

View File

@ -64,11 +64,11 @@ class File extends FileAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function __construct(string $path) public function __construct(string $path)
{ {
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();
} }
@ -124,10 +124,10 @@ class File extends FileAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function index() public function index()
{ {
parent::index(); parent::index();
$this->size = filesize($this->path); $this->size = filesize($this->path);
} }
} }

View File

@ -102,7 +102,7 @@ abstract class FileAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function __construct(string $path) public function __construct(string $path)
{ {
$this->path = $path; $this->path = $path;
$this->name = basename($path); $this->name = basename($path);
@ -145,7 +145,7 @@ abstract class FileAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getName() : string public function getName() : string
{ {
return $this->name; return $this->name;
} }
@ -158,7 +158,7 @@ abstract class FileAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getPath() : string public function getPath() : string
{ {
return $this->path; return $this->path;
} }
@ -171,7 +171,7 @@ abstract class FileAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function parent() : Directory public function parent() : Directory
{ {
return new Directory(Directory::getParent($this->path)); return new Directory(Directory::getParent($this->path));
} }
@ -194,7 +194,7 @@ abstract class FileAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getCreatedAt() : \DateTime public function getCreatedAt() : \DateTime
{ {
return $this->createdAt; return $this->createdAt;
} }
@ -207,7 +207,7 @@ abstract class FileAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getChangedAt() : \DateTime public function getChangedAt() : \DateTime
{ {
return $this->changedAt; return $this->changedAt;
} }
@ -220,7 +220,7 @@ abstract class FileAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getOwner() : int public function getOwner() : int
{ {
return $this->owner; return $this->owner;
} }
@ -233,7 +233,7 @@ abstract class FileAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getPermission() : string public function getPermission() : string
{ {
return $this->permission; return $this->permission;
} }
@ -246,11 +246,11 @@ abstract class FileAbstract
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function index() public function index()
{ {
$this->createdAt->setTimestamp(filemtime($this->path)); $this->createdAt->setTimestamp(filemtime($this->path));
$this->changedAt->setTimestamp(filectime($this->path)); $this->changedAt->setTimestamp(filectime($this->path));
$this->owner = fileowner($this->path); $this->owner = fileowner($this->path);
$this->permission = substr(sprintf('%o', fileperms($this->path)), -4); $this->permission = substr(sprintf('%o', fileperms($this->path)), -4);
} }
} }

View File

@ -30,5 +30,5 @@ namespace phpOMS\System\File;
*/ */
class NullFile extends File class NullFile extends File
{ {
} }

Some files were not shown because too many files have changed in this diff Show More