diff --git a/Account/Account.php b/Account/Account.php index 3484f238b..4c4690077 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -159,6 +159,7 @@ class Account implements ArrayableInterface, \JsonSerializable public function __construct(int $id = 0) { $this->createdAt = new \DateTime('now'); + $this->lastActive = new \DateTime('now'); $this->id = $id; $this->l11n = new NullLocalization(); } @@ -199,11 +200,24 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setL11n(Localization $l11n) + public function setL11n(Localization $l11n) /* : void */ { $this->l11n = $l11n; } + /** + * Get name. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getName() : string + { + return $this->login; + } + /** * Get name1. * @@ -312,6 +326,21 @@ class Account implements ArrayableInterface, \JsonSerializable return $this->createdAt ?? new \DateTime('NOW'); } + /** + * Set name. + * + * @param string $name Name + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setName(string $name) /* : void */ + { + $this->login = $name; + } + /** * Set name1. * @@ -322,7 +351,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName1(string $name) + public function setName1(string $name) /* : void */ { $this->name1 = $name; } @@ -337,7 +366,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName2(string $name) + public function setName2(string $name) /* : void */ { $this->name2 = $name; } @@ -352,7 +381,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName3(string $name) + public function setName3(string $name) /* : void */ { $this->name3 = $name; } @@ -367,7 +396,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setEmail(string $email) + public function setEmail(string $email) /* : void */ { if (!Email::isValid($email)) { throw new \InvalidArgumentException(); @@ -386,7 +415,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setStatus(int $status) + public function setStatus(int $status) /* : void */ { if (!AccountStatus::isValidValue($status)) { throw new \InvalidArgumentException(); @@ -405,7 +434,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setType(int $type) + public function setType(int $type) /* : void */ { if (!AccountType::isValidValue($type)) { throw new \InvalidArgumentException(); diff --git a/Account/AccountManager.php b/Account/AccountManager.php index d39425f57..e665a0711 100644 --- a/Account/AccountManager.php +++ b/Account/AccountManager.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Account/AccountMapper.php b/Account/AccountMapper.php index c8d16a3dc..43c73dd4c 100644 --- a/Account/AccountMapper.php +++ b/Account/AccountMapper.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -25,7 +25,7 @@ class AccountMapper extends DataMapperAbstract /** * Columns. * - * @var array + * @var array * @since 1.0.0 */ protected static $columns = [ diff --git a/Account/AccountStatus.php b/Account/AccountStatus.php index 93bc0d90c..d3db9386a 100644 --- a/Account/AccountStatus.php +++ b/Account/AccountStatus.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -30,8 +30,8 @@ use phpOMS\Datatypes\Enum; */ abstract class AccountStatus extends Enum { - const ACTIVE = 1; - const INACTIVE = 2; - const TIMEOUT = 3; - const BANNED = 4; + /* public */ const ACTIVE = 1; + /* public */ const INACTIVE = 2; + /* public */ const TIMEOUT = 3; + /* public */ const BANNED = 4; } diff --git a/Account/AccountType.php b/Account/AccountType.php index 4c65e6392..2d8d548db 100644 --- a/Account/AccountType.php +++ b/Account/AccountType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -30,6 +30,6 @@ use phpOMS\Datatypes\Enum; */ abstract class AccountType extends Enum { - const USER = 0; - const GROUP = 1; + /* public */ const USER = 0; + /* public */ const GROUP = 1; } diff --git a/Account/Group.php b/Account/Group.php index 03b606361..05da5aa4c 100644 --- a/Account/Group.php +++ b/Account/Group.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -64,14 +64,20 @@ class Group implements ArrayableInterface, \JsonSerializable protected $members = []; /** - * Parents . + * Parents. * * @var int[] * @since 1.0.0 */ protected $parents = []; - private $status = GroupStatus::INACTIVE; + /** + * Group status. + * + * @var int + * @since 1.0.0 + */ + protected $status = GroupStatus::INACTIVE; /** * Permissions. @@ -142,7 +148,7 @@ class Group implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName(string $name) + public function setName(string $name) /* : void */ { $this->name = $name; } @@ -168,18 +174,35 @@ class Group implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setDescription(string $description) + public function setDescription(string $description) /* : void */ { $this->description = $description; } + /** + * Get group status. + * + * @return int Group status + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getStatus() : int { return $this->status; } - public function setStatus(int $status) + /** + * Set group status. + * + * @param int $status Group status + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setStatus(int $status) /* : void */ { + // todo: check valid $this->status = $status; } diff --git a/Account/GroupStatus.php b/Account/GroupStatus.php index 8699f72c8..e0e3ad6f5 100644 --- a/Account/GroupStatus.php +++ b/Account/GroupStatus.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -30,9 +30,9 @@ use phpOMS\Datatypes\Enum; */ abstract class GroupStatus extends Enum { - const ACTIVE = 1; + /* public */ const ACTIVE = 1; - const INACTIVE = 2; + /* public */ const INACTIVE = 2; - const HIDDEN = 4; + /* public */ const HIDDEN = 4; } diff --git a/Account/NullAccount.php b/Account/NullAccount.php index 1feea9cf7..d2f212d1b 100644 --- a/Account/NullAccount.php +++ b/Account/NullAccount.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Algorithm/AlgorithmType.php b/Algorithm/AlgorithmType.php new file mode 100644 index 000000000..ba8c643b7 --- /dev/null +++ b/Algorithm/AlgorithmType.php @@ -0,0 +1,34 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Algorithm; + +use phpOMS\Datatypes\Enum; + +/** + * Task status enum. + * + * @category Tasks + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class AlgorithmType extends Enum +{ + /* public */ const BRUTEFORCE = 0; +} diff --git a/Algorithm/Knappsack/Backpack.php b/Algorithm/Knappsack/Backpack.php new file mode 100644 index 000000000..9054f219f --- /dev/null +++ b/Algorithm/Knappsack/Backpack.php @@ -0,0 +1,91 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Algorithm\Knappsack; +use phpOMS\Algorithm\AlgorithmType; + +/** + * Knappsack algorithm implementations + * + * @category Framework + * @package phpOMS\Auth + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Backpack +{ + private $costMaximum = 0; + + private $value = 0; + + private $cost = 0; + + private $items = []; + + private $population = []; + + public function __construct(float $costMaximum) + { + $this->costMaximum = $costMaximum; + } + + public function addPopulationItem(ItemInterface $item) : bool + { + if(isset($this->population[$item->getId()])) { + return false; + } + + $this->population[$item->getId()] = $item; + + return true; + } + + public function setPopulationItem(ItemInterface $item) /* : void */ + { + $this->population[$item->getId()] = $item; + } + + public function setCostCalculation(\Closure $callback) /* : void */ + { + + } + + public function setValueCalculation(\Closure $callback) /* : void */ + { + + } + + public function setTestPopulationBuilder(\Closure $callback) /* : void */ + { + + } + + public function pack(int $type) + { + switch($type) { + case AlgorithmType::BRUTEFORCE: + return $this->bruteforce(); + default: + throw new \Exception('Invalid algorithm type'); + } + } + + public function bruteforce() + { + } +} \ No newline at end of file diff --git a/Algorithm/Knappsack/ItemInterface.php b/Algorithm/Knappsack/ItemInterface.php new file mode 100644 index 000000000..8def286b5 --- /dev/null +++ b/Algorithm/Knappsack/ItemInterface.php @@ -0,0 +1,32 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Algorithm\Knappsack; + +/** + * Shape interface. + * + * @category Framework + * @package phpOMS\Math + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +interface ItemInterface +{ + +} diff --git a/ApplicationAbstract.php b/ApplicationAbstract.php index a827cf25d..81a8e2a4b 100644 --- a/ApplicationAbstract.php +++ b/ApplicationAbstract.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -37,6 +37,14 @@ class ApplicationAbstract */ public $appName = ''; + /** + * Config. + * + * @var array + * @since 1.0.0 + */ + private $config = []; + /** * Database object. * diff --git a/Asset/AssetManager.php b/Asset/AssetManager.php index c5108af37..23d74e06f 100644 --- a/Asset/AssetManager.php +++ b/Asset/AssetManager.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -101,7 +101,7 @@ class AssetManager implements \Countable * @since 1.0.0 * @author Dennis Eichhorn */ - public function get(string $id) + public function get(string $id) /* : ?string */ { if (isset($this->assets[$id])) { return $this->assets[$id]; diff --git a/Asset/AssetType.php b/Asset/AssetType.php index e7313c97c..394eb6ba1 100644 --- a/Asset/AssetType.php +++ b/Asset/AssetType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -30,7 +30,7 @@ use phpOMS\Datatypes\Enum; */ abstract class AssetType extends Enum { - const CSS = 'css'; - const JS = 'js'; - const JSLATE = 'jslate'; + /* public */ const CSS = 'css'; + /* public */ const JS = 'js'; + /* public */ const JSLATE = 'jslate'; } diff --git a/Auth/Auth.php b/Auth/Auth.php index 284083f24..53da003ab 100644 --- a/Auth/Auth.php +++ b/Auth/Auth.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Auth/LoginReturnType.php b/Auth/LoginReturnType.php index dc5a886af..659bfe8a0 100644 --- a/Auth/LoginReturnType.php +++ b/Auth/LoginReturnType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -32,14 +32,14 @@ use phpOMS\Datatypes\Enum; */ abstract class LoginReturnType extends Enum { - const OK = 0; /* Everything is ok and the user got authed */ - const FAILURE = 1; /* Authentication resulted in a unexpected failure */ - const WRONG_PASSWORD = 2; /* Authentication with wrong password */ - const WRONG_USERNAME = 3; /* Authentication with unknown user */ - const WRONG_PERMISSION = 4; /* User doesn't have permission to authenticate */ - const NOT_ACTIVATED = 5; /* The user is not activated yet */ - 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 BANNED = 8; /* User is banned */ - const INACTIVE = 9; /* User is inactive */ + /* public */ const OK = 0; /* Everything is ok and the user got authed */ + /* public */ const FAILURE = 1; /* Authentication resulted in a unexpected failure */ + /* public */ const WRONG_PASSWORD = 2; /* Authentication with wrong password */ + /* public */ const WRONG_USERNAME = 3; /* Authentication with unknown user */ + /* public */ const WRONG_PERMISSION = 4; /* User doesn't have permission to authenticate */ + /* public */ const NOT_ACTIVATED = 5; /* The user is not activated yet */ + /* public */ const WRONG_INPUT_EXCEEDED = 6; /* Too many wrong logins recently */ + /* public */ const TIMEOUTED = 7; /* User received a timeout and can not log in until a certain date */ + /* public */ const BANNED = 8; /* User is banned */ + /* public */ const INACTIVE = 9; /* User is inactive */ } diff --git a/AutoloadException.php b/AutoloadException.php index 28b8322e0..8173b260b 100644 --- a/AutoloadException.php +++ b/AutoloadException.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Autoloader.php b/Autoloader.php index f19cc431c..3cd600847 100644 --- a/Autoloader.php +++ b/Autoloader.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -44,7 +44,7 @@ class Autoloader * @since 1.0.0 * @author Dennis Eichhorn */ - public static function default_autoloader(string $class) + public static function default_autoloader(string $class) /* : void */ { $class = ltrim($class, '\\'); $class = str_replace(['_', '\\'], '/', $class); diff --git a/Config/OptionsInterface.php b/Config/OptionsInterface.php index 8066a9558..a506bb6f9 100644 --- a/Config/OptionsInterface.php +++ b/Config/OptionsInterface.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Config/OptionsTrait.php b/Config/OptionsTrait.php index 0ecec2485..967be0a9b 100644 --- a/Config/OptionsTrait.php +++ b/Config/OptionsTrait.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -36,7 +36,7 @@ trait OptionsTrait /** * {@inheritdoc} */ - public function exists($key) + public function exists($key) : bool { return isset($this->options[$key]); } diff --git a/Config/SettingsAbstract.php b/Config/SettingsAbstract.php index f14798ec2..a50409466 100644 --- a/Config/SettingsAbstract.php +++ b/Config/SettingsAbstract.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -39,7 +39,7 @@ abstract class SettingsAbstract implements OptionsInterface /** * Cache manager (pool). * - * @var \phpOMS\DataStorage\Cache\Pool + * @var \phpOMS\DataStorage\Cache\CachePool * @since 1.0.0 */ protected $cache = null; @@ -131,7 +131,7 @@ abstract class SettingsAbstract implements OptionsInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function set(array $options, bool $store = false) + public function set(array $options, bool $store = false) /* : void */ { $this->setOptions($options); diff --git a/Console/CommandManager.php b/Console/CommandManager.php index e14f570f8..005f110e6 100644 --- a/Console/CommandManager.php +++ b/Console/CommandManager.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Contract/ArrayableInterface.php b/Contract/ArrayableInterface.php index eac648ca8..2d08f6b95 100644 --- a/Contract/ArrayableInterface.php +++ b/Contract/ArrayableInterface.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Contract/Object.php b/Contract/Object.php index aafdf1991..336fe5f0b 100644 --- a/Contract/Object.php +++ b/Contract/Object.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Contract/RenderableInterface.php b/Contract/RenderableInterface.php index b711a7173..2d3e1e11e 100644 --- a/Contract/RenderableInterface.php +++ b/Contract/RenderableInterface.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Cache/CacheFactory.php b/DataStorage/Cache/CacheFactory.php index eb126955e..713f0f958 100644 --- a/DataStorage/Cache/CacheFactory.php +++ b/DataStorage/Cache/CacheFactory.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Cache/CacheInterface.php b/DataStorage/Cache/CacheInterface.php index c53eb3b5b..e15442cf3 100644 --- a/DataStorage/Cache/CacheInterface.php +++ b/DataStorage/Cache/CacheInterface.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Cache/CachePool.php b/DataStorage/Cache/CachePool.php index 3f578bfef..aac93d82e 100644 --- a/DataStorage/Cache/CachePool.php +++ b/DataStorage/Cache/CachePool.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Cache/CacheStatus.php b/DataStorage/Cache/CacheStatus.php index 527f2c584..c74e9fc42 100644 --- a/DataStorage/Cache/CacheStatus.php +++ b/DataStorage/Cache/CacheStatus.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -32,7 +32,7 @@ use phpOMS\Datatypes\Enum; */ abstract class CacheStatus extends Enum { - const ACTIVE = 0; - const INACTIVE = 1; - const ERROR = 2; + /* public */ const ACTIVE = 0; + /* public */ const INACTIVE = 1; + /* public */ const ERROR = 2; } diff --git a/DataStorage/Cache/CacheType.php b/DataStorage/Cache/CacheType.php index 36960335e..36407bbec 100644 --- a/DataStorage/Cache/CacheType.php +++ b/DataStorage/Cache/CacheType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -32,11 +32,11 @@ use phpOMS\Datatypes\Enum; */ abstract class CacheType extends Enum { - const _INT = 0; /* Data is integer */ - const _STRING = 1; /* Data is string */ - const _ARRAY = 2; /* Data is array */ - const _SERIALIZABLE = 3; /* Data is object */ - const _JSONSERIALIZABLE = 6; - const _FLOAT = 4; /* Data is float */ - const _BOOL = 5; /* Data is float */ + /* public */ const _INT = 0; /* Data is integer */ + /* public */ const _STRING = 1; /* Data is string */ + /* public */ const _ARRAY = 2; /* Data is array */ + /* public */ const _SERIALIZABLE = 3; /* Data is object */ + /* public */ const _JSONSERIALIZABLE = 6; + /* public */ const _FLOAT = 4; /* Data is float */ + /* public */ const _BOOL = 5; /* Data is float */ } diff --git a/DataStorage/Cache/FileCache.php b/DataStorage/Cache/FileCache.php index 44657bda5..a4725997f 100644 --- a/DataStorage/Cache/FileCache.php +++ b/DataStorage/Cache/FileCache.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -22,7 +22,7 @@ use phpOMS\System\File\Local\File; /** * MemCache class. * - * PHP Version 5.6 + * PHP Version 7.1 * * @category Framework * @package phpOMS\DataStorage\Cache @@ -41,7 +41,15 @@ class FileCache implements CacheInterface * @var string * @since 1.0.0 */ - const DELIM = '$'; + /* private */ const DELIM = '$'; + + /** + * File path sanitizer + * + * @var string + * @since 1.0.0 + */ + /* private */ const SANITIZE = '~'; /** * Cache path. @@ -136,15 +144,16 @@ class FileCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, int $expire = -1) + public function set($key, $value, int $expire = -1) /* : void */ { if($this->status !== CacheStatus::ACTIVE) { return false; } - $path = File::sanitize($key, '~'); + // todo: allow $key to contain / as char and create subdirectory if necessary. This is important for cleaner caching. + $path = File::sanitize($key, self::SANITIZE); - file_put_contents($this->cachePath . '/' . $path . '.cache', $this->build($value, $expire)); + file_put_contents($this->cachePath . '/' . trim($path, '/') . '.cache', $this->build($value, $expire)); return false; } @@ -158,8 +167,8 @@ class FileCache implements CacheInterface return false; } - $name = File::sanitize($key, '~'); - $path = $this->cachePath . '/' . $path . '.cache'; + $path = File::sanitize($key, self::SANITIZE); + $path = $this->cachePath . '/' . trim($path, '/') . '.cache'; if (!file_exists($path)) { file_put_contents($path, $this->build($value, $expire)); @@ -275,8 +284,8 @@ class FileCache implements CacheInterface return null; } - $name = File::sanitize($key, '~'); - $path = $this->cachePath . '/' . $name . '.cache'; + $name = File::sanitize($key, self::SANITIZE); + $path = $this->cachePath . '/' . trim($name, '/') . '.cache'; if(!file_exists($path)) { return null; @@ -342,8 +351,8 @@ class FileCache implements CacheInterface return false; } - $name = File::sanitize($key, '~'); - $path = $this->cachePath . '/' . $name . '.cache'; + $name = File::sanitize($key, self::SANITIZE); + $path = $this->cachePath . '/' . trim($name, '/') . '.cache'; if ($expire < 0 && file_exists($path)) { unlink($path); @@ -405,8 +414,8 @@ class FileCache implements CacheInterface return false; } - $name = File::sanitize($key, '~'); - $path = $this->cachePath . '/' . $path . '.cache'; + $name = File::sanitize($key, self::SANITIZE); + $path = $this->cachePath . '/' . trim($path, '/') . '.cache'; if (file_exists($path)) { file_put_contents($path, $this->build($value, $expire)); diff --git a/DataStorage/Cache/MemCache.php b/DataStorage/Cache/MemCache.php index f14d7bcda..7f82dfe5c 100644 --- a/DataStorage/Cache/MemCache.php +++ b/DataStorage/Cache/MemCache.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -74,7 +74,7 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, CacheStatus $type = null, int $expire = 2592000) + public function set($key, $value, int $expire = -1) /* : void */ { $this->memc->set($key, $value, false, $expire); } @@ -82,7 +82,7 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function add($key, $value, CacheStatus $type = null, int $expire = 2592000) : bool + public function add($key, $value, int $expire = -1) : bool { return $this->memc->add($key, $value, false, $expire); } @@ -90,7 +90,7 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function get($key, CacheStatus $type = null) + public function get($key, int $expire = -1) { return $this->memc->get($key); } @@ -98,7 +98,7 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function delete($key, CacheStatus $type = null) : bool + public function delete($key, int $expire = -1) : bool { $this->memc->delete($key); } @@ -106,15 +106,27 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function flush(CacheStatus $type = null) + public function flush(int $expire = 0) : bool { $this->memc->flush(); + + return true; } /** * {@inheritdoc} */ - public function replace($key, $value, CacheType $type = null, int $expire = -1) : bool + public function flushAll() : bool + { + $this->memc->flush(); + + return true; + } + + /** + * {@inheritdoc} + */ + public function replace($key, $value, int $expire = -1) : bool { $this->memc->replace($key, $value, false, $expire); } @@ -136,6 +148,14 @@ class MemCache implements CacheInterface return $this->threshold; } + /** + * {@inheritdoc} + */ + public function setStatus(int $status) /* : void */ + { + $this->status = $status; + } + /** * Destructor. * diff --git a/DataStorage/Cache/NullCache.php b/DataStorage/Cache/NullCache.php index 404ee2cd2..ad4c1baf3 100644 --- a/DataStorage/Cache/NullCache.php +++ b/DataStorage/Cache/NullCache.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -32,7 +32,7 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, CacheStatus $type = null, int $expire = 2592000) + public function set($key, $value, int $expire = -1) /* : void */ { // TODO: Implement set() method. } @@ -40,7 +40,7 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function add($key, $value, CacheStatus $type = null, int $expire = 2592000) : bool + public function add($key, $value, int $expire = -1) : bool { // TODO: Implement add() method. } @@ -48,7 +48,7 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function get($key, CacheStatus $type = null) + public function get($key, int $expire = -1) { // TODO: Implement get() method. } @@ -56,7 +56,7 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function delete($key, CacheStatus $type = null) : bool + public function delete($key, int $expire = -1) : bool { // TODO: Implement delete() method. } @@ -64,15 +64,27 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function flush(CacheStatus $type = null) + public function flush(int $expire = 0) : bool { // TODO: Implement flush() method. + + return true; } /** * {@inheritdoc} */ - public function replace($key, $value, CacheType $type = null, int $expire = -1) : bool + public function flushAll() : bool + { + // TODO: Implement flush() method. + + return true; + } + + /** + * {@inheritdoc} + */ + public function replace($key, $value, int $expire = -1) : bool { // TODO: Implement replace() method. } @@ -93,4 +105,11 @@ class NullCache implements CacheInterface // TODO: Implement getThreshold() method. } + /** + * {@inheritdoc} + */ + public function setStatus(int $status) /* : void */ + { + // TODO: Implement setStatus() method. + } } diff --git a/DataStorage/Cache/RedisCache.php b/DataStorage/Cache/RedisCache.php index e93fb1167..42282a213 100644 --- a/DataStorage/Cache/RedisCache.php +++ b/DataStorage/Cache/RedisCache.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -34,7 +34,7 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, CacheStatus $type = null, int $expire = 2592000) + public function set($key, $value, int $expire = -1) /* : void */ { // TODO: Implement set() method. } @@ -42,7 +42,7 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function add($key, $value, CacheStatus $type = null, int $expire = 2592000) : bool + public function add($key, $value, int $expire = -1) : bool { // TODO: Implement add() method. } @@ -50,7 +50,7 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function get($key, CacheStatus $type = null) + public function get($key, int $expire = -1) { // TODO: Implement get() method. } @@ -58,7 +58,7 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function delete($key, CacheStatus $type = null) : bool + public function delete($key, int $expire = -1) : bool { // TODO: Implement delete() method. } @@ -66,15 +66,27 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function flush(CacheStatus $type = null) + public function flush(int $expire = 0) : bool { // TODO: Implement flush() method. + + return true; } /** * {@inheritdoc} */ - public function replace($key, $value, CacheType $type = null, int $expire = -1) : bool + public function flushAll() : bool + { + // TODO: Implement flush() method. + + return true; + } + + /** + * {@inheritdoc} + */ + public function replace($key, $value, int $expire = -1) : bool { // TODO: Implement replace() method. } @@ -95,4 +107,11 @@ class RedisCache implements CacheInterface // TODO: Implement getThreshold() method. } + /** + * {@inheritdoc} + */ + public function setStatus(int $status) /* : void */ + { + // TODO: Implement setStatus() method. + } } diff --git a/DataStorage/Cache/WinCache.php b/DataStorage/Cache/WinCache.php index 0690cded2..842ed8562 100644 --- a/DataStorage/Cache/WinCache.php +++ b/DataStorage/Cache/WinCache.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -34,7 +34,7 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, CacheStatus $type = null, int $expire = 2592000) + public function set($key, $value, int $expire = -1) /* : void */ { // TODO: Implement set() method. } @@ -42,7 +42,7 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function add($key, $value, CacheStatus $type = null, int $expire = 2592000) : bool + public function add($key, $value, int $expire = -1) : bool { // TODO: Implement add() method. } @@ -50,7 +50,7 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function get($key, CacheStatus $type = null) + public function get($key, int $expire = -1) { // TODO: Implement get() method. } @@ -58,7 +58,7 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function delete($key, CacheStatus $type = null) : bool + public function delete($key, int $expire = -1) : bool { // TODO: Implement delete() method. } @@ -66,15 +66,27 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function flush(CacheStatus $type = null) + public function flush(int $expire = 0) : bool { // TODO: Implement flush() method. + + return true; } /** * {@inheritdoc} */ - public function replace($key, $value, CacheType $type = null, int $expire = -1) : bool + public function flushAll() : bool + { + // TODO: Implement flush() method. + + return true; + } + + /** + * {@inheritdoc} + */ + public function replace($key, $value, int $expire = -1) : bool { // TODO: Implement replace() method. } @@ -95,4 +107,11 @@ class WinCache implements CacheInterface // TODO: Implement getThreshold() method. } + /** + * {@inheritdoc} + */ + public function setStatus(int $status) /* : void */ + { + // TODO: Implement setStatus() method. + } } diff --git a/DataStorage/Cookie/CookieJar.php b/DataStorage/Cookie/CookieJar.php index 958c17235..113df613f 100644 --- a/DataStorage/Cookie/CookieJar.php +++ b/DataStorage/Cookie/CookieJar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -63,7 +63,7 @@ class CookieJar * @since 1.0.0 * @author Dennis Eichhorn */ - public static function lock() + public static function lock() /* : void */ { self::$isLocked = true; } @@ -126,7 +126,7 @@ class CookieJar * @since 1.0.0 * @author Dennis Eichhorn */ - public function delete(string $id) + public function delete(string $id) /* : void */ { $this->remove($id); setcookie($id, '', time() - 3600); @@ -156,10 +156,14 @@ class CookieJar /** * Save cookie * + * @return void + * + * @throws LockException + * * @since 1.0.0 * @author Dennis Eichhorn */ - public function save() + public function save() /* : void */ { if (self::$isLocked) { throw new LockException('CookieJar'); diff --git a/DataStorage/DataMapperInterface.php b/DataStorage/DataMapperInterface.php index 0a9c23218..c4aa5d03d 100644 --- a/DataStorage/DataMapperInterface.php +++ b/DataStorage/DataMapperInterface.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/BuilderAbstract.php b/DataStorage/Database/BuilderAbstract.php index 3e016245c..1783ff6d0 100644 --- a/DataStorage/Database/BuilderAbstract.php +++ b/DataStorage/Database/BuilderAbstract.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -68,12 +68,12 @@ abstract class BuilderAbstract * * @param string $prefix Prefix * - * @return $this + * @return BuilderAbstract * * @since 1.0.0 * @author Dennis Eichhorn */ - public function prefix(string $prefix) + public function prefix(string $prefix) : BuilderAbstract { $this->prefix = $prefix; diff --git a/DataStorage/Database/Connection/ConnectionAbstract.php b/DataStorage/Database/Connection/ConnectionAbstract.php index e49619dac..f2d78f2c2 100644 --- a/DataStorage/Database/Connection/ConnectionAbstract.php +++ b/DataStorage/Database/Connection/ConnectionAbstract.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -165,7 +165,7 @@ abstract class ConnectionAbstract implements ConnectionInterface /** * {@inheritdoc} */ - public function close() + public function close() /* : void */ { $this->con = null; $this->status = DatabaseStatus::CLOSED; diff --git a/DataStorage/Database/Connection/ConnectionException.php b/DataStorage/Database/Connection/ConnectionException.php index 6a26aeb8a..16df8f16d 100644 --- a/DataStorage/Database/Connection/ConnectionException.php +++ b/DataStorage/Database/Connection/ConnectionException.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Connection/ConnectionFactory.php b/DataStorage/Database/Connection/ConnectionFactory.php index 6a215faa4..0b82404a3 100644 --- a/DataStorage/Database/Connection/ConnectionFactory.php +++ b/DataStorage/Database/Connection/ConnectionFactory.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Connection/ConnectionInterface.php b/DataStorage/Database/Connection/ConnectionInterface.php index 935902421..31fd426b7 100644 --- a/DataStorage/Database/Connection/ConnectionInterface.php +++ b/DataStorage/Database/Connection/ConnectionInterface.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -44,7 +44,7 @@ interface ConnectionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function connect(array $dbdata); + public function connect(array $dbdata) /* : void */; /** * Get the database type. @@ -74,7 +74,7 @@ interface ConnectionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function close(); + public function close() /* : void */; /** * Return grammar for this connection. diff --git a/DataStorage/Database/Connection/MysqlConnection.php b/DataStorage/Database/Connection/MysqlConnection.php index 937b6b87a..999e7e91a 100644 --- a/DataStorage/Database/Connection/MysqlConnection.php +++ b/DataStorage/Database/Connection/MysqlConnection.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -58,7 +58,7 @@ class MysqlConnection extends ConnectionAbstract /** * {@inheritdoc} */ - public function connect(array $dbdata = null) + public function connect(array $dbdata = null) /* : void */ { $this->close(); diff --git a/DataStorage/Database/Connection/PostgresConnection.php b/DataStorage/Database/Connection/PostgresConnection.php index 57323f881..13d8e0a0a 100644 --- a/DataStorage/Database/Connection/PostgresConnection.php +++ b/DataStorage/Database/Connection/PostgresConnection.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Connection/SQLiteConnection.php b/DataStorage/Database/Connection/SQLiteConnection.php index 7e45256fe..64182c489 100644 --- a/DataStorage/Database/Connection/SQLiteConnection.php +++ b/DataStorage/Database/Connection/SQLiteConnection.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Connection/SqlServerConnection.php b/DataStorage/Database/Connection/SqlServerConnection.php index b8779b650..05525cdb6 100644 --- a/DataStorage/Database/Connection/SqlServerConnection.php +++ b/DataStorage/Database/Connection/SqlServerConnection.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -57,7 +57,7 @@ class SqlServerConnection extends ConnectionAbstract /** * {@inheritdoc} */ - public function connect(array $dbdata = null) + public function connect(array $dbdata = null) /* : void */ { $this->close(); diff --git a/DataStorage/Database/Connector/MysqlConnector.php b/DataStorage/Database/Connector/MysqlConnector.php index a694f4cc0..fc0cf3c52 100644 --- a/DataStorage/Database/Connector/MysqlConnector.php +++ b/DataStorage/Database/Connector/MysqlConnector.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Connector/PostgresConnector.php b/DataStorage/Database/Connector/PostgresConnector.php index 36a14c522..7668d8ae5 100644 --- a/DataStorage/Database/Connector/PostgresConnector.php +++ b/DataStorage/Database/Connector/PostgresConnector.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Connector/SQLiteConnector.php b/DataStorage/Database/Connector/SQLiteConnector.php index ba79d563d..1d5f9381b 100644 --- a/DataStorage/Database/Connector/SQLiteConnector.php +++ b/DataStorage/Database/Connector/SQLiteConnector.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Connector/SqlServerConnector.php b/DataStorage/Database/Connector/SqlServerConnector.php index 07bf7aaf4..7f24a49d6 100644 --- a/DataStorage/Database/Connector/SqlServerConnector.php +++ b/DataStorage/Database/Connector/SqlServerConnector.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index c8f97415f..c2e948cbe 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -70,7 +70,7 @@ class DataMapperAbstract implements DataMapperInterface /** * Columns. * - * @var array + * @var array * @since 1.0.0 */ protected static $columns = []; @@ -175,7 +175,7 @@ class DataMapperAbstract implements DataMapperInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function setConnection(ConnectionAbstract $con) + public static function setConnection(ConnectionAbstract $con) /* : void */ { self::$db = $con; } @@ -216,7 +216,7 @@ class DataMapperAbstract implements DataMapperInterface * @since 1.0.0 * @author Dennis Eichhorn */ - private static function extend($class) + private static function extend($class) /* : void */ { /* todo: have to implement this in the queries, so far not used */ self::$collection['primaryField'][] = $class::$primaryField; @@ -264,7 +264,7 @@ class DataMapperAbstract implements DataMapperInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function with(...$objects) + public static function with(...$objects) /* : void */ { // todo: how to handle with of parent objects/extends/relations @@ -283,7 +283,7 @@ class DataMapperAbstract implements DataMapperInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function clear() + public static function clear() /* : void */ { self::$overwrite = true; self::$primaryField = ''; @@ -337,8 +337,6 @@ class DataMapperAbstract implements DataMapperInterface * * @return mixed * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -427,7 +425,7 @@ class DataMapperAbstract implements DataMapperInterface * @since 1.0.0 * @author Dennis Eichhorn */ - private static function setObjectId(\ReflectionClass $reflectionClass, $obj, $objId) + private static function setObjectId(\ReflectionClass $reflectionClass, $obj, $objId) /* : void */ { $reflectionProperty = $reflectionClass->getProperty(static::$columns[static::$primaryField]['internal']); @@ -452,7 +450,7 @@ class DataMapperAbstract implements DataMapperInterface * * @return void * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -552,8 +550,6 @@ class DataMapperAbstract implements DataMapperInterface * * @return mixed * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -588,8 +584,6 @@ class DataMapperAbstract implements DataMapperInterface * * @return mixed * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -617,7 +611,7 @@ class DataMapperAbstract implements DataMapperInterface /** * Create relation table entry * - * In cas of a many to many relation the relation has to be stored in a relation table + * In case of a many to many relation the relation has to be stored in a relation table * * @param string $propertyName Property name to initialize * @param array $objsIds Object ids to insert @@ -625,15 +619,17 @@ class DataMapperAbstract implements DataMapperInterface * * @return mixed * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ private static function createRelationTable(string $propertyName, array $objsIds, $objId) { /** @var string $table */ - if (static::$hasMany[$propertyName]['table'] !== static::$table && static::$hasMany[$propertyName]['table'] !== static::$hasMany[$propertyName]['mapper']::$table) { + if ( + !empty($objsIds) + && static::$hasMany[$propertyName]['table'] !== static::$table + && static::$hasMany[$propertyName]['table'] !== static::$hasMany[$propertyName]['mapper']::$table + ) { $relQuery = new Builder(self::$db); $relQuery->prefix(self::$db->getPrefix()) ->into(static::$hasMany[$propertyName]['table']) @@ -692,8 +688,6 @@ class DataMapperAbstract implements DataMapperInterface * * @return int * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -824,7 +818,7 @@ class DataMapperAbstract implements DataMapperInterface } $objects = $mapper::get($values); - $reflectionProperty->setValue($obj, $objects); + $reflectionProperty->setValue($obj, !is_array($objects) ? [$objects] : $objects); if (!$accessible) { $reflectionProperty->setAccessible(false); @@ -1152,7 +1146,7 @@ class DataMapperAbstract implements DataMapperInterface { $query = new Builder(self::$db); $query->prefix(self::$db->getPrefix()) - ->random(static::$primaryKey) + ->random(static::$primaryField) ->from(static::$table) ->limit($amount); @@ -1336,6 +1330,8 @@ class DataMapperAbstract implements DataMapperInterface /** * Get model based on request object * + * @todo: change to graphql + * * @param RequestAbstract $request Request object * * @return mixed diff --git a/DataStorage/Database/DatabaseExceptionFactory.php b/DataStorage/Database/DatabaseExceptionFactory.php index cc5000f5b..354a47063 100644 --- a/DataStorage/Database/DatabaseExceptionFactory.php +++ b/DataStorage/Database/DatabaseExceptionFactory.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/DatabasePool.php b/DataStorage/Database/DatabasePool.php index ca9a19b7b..73c06f124 100644 --- a/DataStorage/Database/DatabasePool.php +++ b/DataStorage/Database/DatabasePool.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -78,15 +78,15 @@ class DatabasePool * * @param mixed $key Database key * - * @return ConnectionAbstract|false + * @return ConnectionAbstract|null * * @since 1.0.0 * @author Dennis Eichhorn */ - public function get(string $key = 'core') + public function get(string $key = 'core') /* : ?ConnectionAbstract */ { if (!isset($this->pool[$key])) { - return false; /* todo: return nullconnection */ + return null; /* todo: return nullconnection */ } return $this->pool[$key]; diff --git a/DataStorage/Database/DatabaseStatus.php b/DataStorage/Database/DatabaseStatus.php index bdb324fa6..08e70f360 100644 --- a/DataStorage/Database/DatabaseStatus.php +++ b/DataStorage/Database/DatabaseStatus.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -32,10 +32,10 @@ use phpOMS\Datatypes\Enum; */ abstract class DatabaseStatus extends Enum { - const OK = 0; /* Database connection successful */ - const MISSING_DATABASE = 1; /* Couldn't find database */ - const MISSING_TABLE = 2; /* One of the core tables couldn't be found */ - const FAILURE = 3; /* Unknown failure */ - const READONLY = 4; /* Database connection is in readonly (but ok) */ - const CLOSED = 5; /* Database connection closed */ + /* public */ const OK = 0; /* Database connection successful */ + /* public */ const MISSING_DATABASE = 1; /* Couldn't find database */ + /* public */ const MISSING_TABLE = 2; /* One of the core tables couldn't be found */ + /* public */ const FAILURE = 3; /* Unknown failure */ + /* public */ const READONLY = 4; /* Database connection is in readonly (but ok) */ + /* public */ const CLOSED = 5; /* Database connection closed */ } diff --git a/DataStorage/Database/DatabaseType.php b/DataStorage/Database/DatabaseType.php index d1b163cf6..42c97e6c2 100644 --- a/DataStorage/Database/DatabaseType.php +++ b/DataStorage/Database/DatabaseType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -32,9 +32,9 @@ use phpOMS\Datatypes\Enum; */ abstract class DatabaseType extends Enum { - const MYSQL = 0; /* MySQL */ - const SQLITE = 1; /* SQLITE */ - const PGSQL = 2; /* PostgreSQL */ - const ORACLE = 3; /* Oracle */ - const SQLSRV = 4; /* Microsoft SQL Server */ + /* public */ const MYSQL = 0; /* MySQL */ + /* public */ const SQLITE = 1; /* SQLITE */ + /* public */ const PGSQL = 2; /* PostgreSQL */ + /* public */ const ORACLE = 3; /* Oracle */ + /* public */ const SQLSRV = 4; /* Microsoft SQL Server */ } diff --git a/DataStorage/Database/GrammarAbstract.php b/DataStorage/Database/GrammarAbstract.php index c3e716bd3..c5ca0300a 100644 --- a/DataStorage/Database/GrammarAbstract.php +++ b/DataStorage/Database/GrammarAbstract.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -69,6 +69,12 @@ abstract class GrammarAbstract */ protected $or = 'OR'; + /** + * Table prefix. + * + * @var string + * @since 1.0.0 + */ protected $tablePrefix = ''; /** @@ -78,8 +84,6 @@ abstract class GrammarAbstract * * @return string * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -97,19 +101,53 @@ abstract class GrammarAbstract ) . ';'; } + /** + * Compile query components. + * + * @param BuilderAbstract $query Builder + * + * @return array Parsed query components + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ abstract protected function compileComponents(BuilderAbstract $query) : array; + /** + * Get date format. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getDateFormat() : string { return 'Y-m-d H:i:s'; } + /** + * Get table prefix. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getTablePrefix() : string { return $this->tablePrefix; } - public function setTablePrefix(string $prefix) + /** + * Set table prefix. + * + * @param string $prefix Table prefix + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setTablePrefix(string $prefix) /* : void */ { $this->tablePrefix = $prefix; } diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index 0cfa63f4c..226770fec 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -173,7 +173,7 @@ class Builder extends BuilderAbstract * @var string[] * @since 1.0.0 */ - const operators = [ + /* public */ const operators = [ '=', '<', '>', @@ -226,7 +226,7 @@ class Builder extends BuilderAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setConnection(ConnectionAbstract $connection) + public function setConnection(ConnectionAbstract $connection) /* : void */ { $this->connection = $connection; $this->grammar = $connection->getGrammar(); @@ -429,7 +429,7 @@ class Builder extends BuilderAbstract * * @return Builder * - * @throws + * @throws \InvalidArgumentException * * @since 1.0.0 * @author Dennis Eichhorn @@ -481,7 +481,7 @@ class Builder extends BuilderAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function andWhere(Where $where) + public function andWhere(Where $where) : Builder { $this->wheres[][] = [ 'column' => $where, @@ -501,7 +501,7 @@ class Builder extends BuilderAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function orWhere(Where $where) + public function orWhere(Where $where) : Builder { $this->wheres[][] = [ 'column' => $where, @@ -704,43 +704,103 @@ class Builder extends BuilderAbstract return $this; } + /** + * Lock query. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function lock() { } + /** + * Lock for update query. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function lockUpdate() { } + /** + * Create query string. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __toString() { return $this->grammar->compileQuery($this); } + /** + * Find query. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function find() { } + /** + * Count results. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function count() { } + /** + * Check if exists. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function exists() { } + /** + * Select minimum. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function min() { } + /** + * Select maximum. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function max() { } + /** + * Select sum. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function sum() { } + /** + * Select average. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function avg() { } @@ -821,6 +881,16 @@ class Builder extends BuilderAbstract return $this; } + /** + * Update columns. + * + * @param array $columns Column names to update + * + * @return Builder + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function update(...$columns) : Builder { $this->type = QueryType::UPDATE; @@ -832,44 +902,106 @@ class Builder extends BuilderAbstract return $this; } + /** + * Increment value. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function increment() { } + /** + * Decrement value. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function decrement() { } + /** + * Join. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function join($table1, $table2, $column1, $opperator, $column2) { return $this; } + /** + * Join where. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function joinWhere() { } + /** + * Left join. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function leftJoin() { } + /** + * Left join where. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function leftJoinWhere() { } + /** + * Right join. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function rightJoin() { } + /** + * Right join where. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function rightJoinWhere() { } + /** + * Rollback. + * + * @return Builder + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function rollback() { return $this; } + /** + * On. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function on() { @@ -892,6 +1024,14 @@ class Builder extends BuilderAbstract return clone($this); } + /** + * Execute query. + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function execute() { $sth = $this->connection->con->prepare($this->toSql()); diff --git a/DataStorage/Database/Query/Column.php b/DataStorage/Database/Query/Column.php index 1587e7c2b..102d1ab97 100644 --- a/DataStorage/Database/Query/Column.php +++ b/DataStorage/Database/Query/Column.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -64,7 +64,7 @@ class Column return $this->column; } - public function setColumn(string $column) + public function setColumn(string $column) /* : void */ { $this->column = $column; } diff --git a/DataStorage/Database/Query/Expression.php b/DataStorage/Database/Query/Expression.php index 5197d627d..07aebce8c 100644 --- a/DataStorage/Database/Query/Expression.php +++ b/DataStorage/Database/Query/Expression.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Query/Grammar/Grammar.php b/DataStorage/Database/Query/Grammar/Grammar.php index bd3b188a1..e9a2d771e 100644 --- a/DataStorage/Database/Query/Grammar/Grammar.php +++ b/DataStorage/Database/Query/Grammar/Grammar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -98,7 +98,7 @@ class Grammar extends GrammarAbstract * * @return string[] * - * @throws + * @throws \InvalidArgumentException * * @since 1.0.0 * @author Dennis Eichhorn @@ -214,6 +214,18 @@ class Grammar extends GrammarAbstract return 'WHERE ' . $expression; } + /** + * Compile where element. + * + * @param array $element Element data + * @param Builder $query Query builder + * @param bool $first Is first element (usefull for nesting) + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ protected function compileWhereElement(array $element, Builder $query, bool $first = true) : string { $expression = ''; @@ -265,6 +277,9 @@ class Grammar extends GrammarAbstract return $value; } + // todo: fix for injection + // todo: implement binding + return $this->valueQuotes . $value . $this->valueQuotes; } elseif (is_int($value)) { return $value; diff --git a/DataStorage/Database/Query/Grammar/GrammarInterface.php b/DataStorage/Database/Query/Grammar/GrammarInterface.php index 741483ccc..55232ae58 100644 --- a/DataStorage/Database/Query/Grammar/GrammarInterface.php +++ b/DataStorage/Database/Query/Grammar/GrammarInterface.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Query/Grammar/MicrosoftGrammar.php b/DataStorage/Database/Query/Grammar/MicrosoftGrammar.php index a1f5780ed..296d84005 100644 --- a/DataStorage/Database/Query/Grammar/MicrosoftGrammar.php +++ b/DataStorage/Database/Query/Grammar/MicrosoftGrammar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Query/Grammar/MysqlGrammar.php b/DataStorage/Database/Query/Grammar/MysqlGrammar.php index ad7dc54e8..43b4663da 100644 --- a/DataStorage/Database/Query/Grammar/MysqlGrammar.php +++ b/DataStorage/Database/Query/Grammar/MysqlGrammar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Query/Grammar/OracleGrammar.php b/DataStorage/Database/Query/Grammar/OracleGrammar.php index e89bd8431..afdf3c650 100644 --- a/DataStorage/Database/Query/Grammar/OracleGrammar.php +++ b/DataStorage/Database/Query/Grammar/OracleGrammar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Query/Grammar/PostgresGrammar.php b/DataStorage/Database/Query/Grammar/PostgresGrammar.php index 682fa397c..619affdcd 100644 --- a/DataStorage/Database/Query/Grammar/PostgresGrammar.php +++ b/DataStorage/Database/Query/Grammar/PostgresGrammar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Query/Grammar/SQLiteGrammar.php b/DataStorage/Database/Query/Grammar/SQLiteGrammar.php index be6d75fd9..0e0355a66 100644 --- a/DataStorage/Database/Query/Grammar/SQLiteGrammar.php +++ b/DataStorage/Database/Query/Grammar/SQLiteGrammar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Query/JoinType.php b/DataStorage/Database/Query/JoinType.php index 6704e0f9d..9d3b09716 100644 --- a/DataStorage/Database/Query/JoinType.php +++ b/DataStorage/Database/Query/JoinType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -30,15 +30,15 @@ use phpOMS\Datatypes\Enum; */ abstract class JoinType extends Enum { - const JOIN = 'JOIN'; - const LEFT_JOIN = 'LEFT JOIN'; - const LEFT_OUTER_JOIN = 'LEFT OUTER JOIN'; - const LEFT_INNER_JOIN = 'LEFT INNER JOIN'; - const RIGHT_JOIN = 'RIGHT JOIN'; - const RIGHT_OUTER_JOIN = 'RIGHT OUTER JOIN'; - const RIGHT_INNER_JOIN = 'RIGHT INNER JOIN'; - const OUTER_JOIN = 'OUTER JOIN'; - const INNER_JOIN = 'INNER JOIN'; - const CROSS_JOIN = 'CROSS JOIN'; - const FULL_OUTER_JOIN = 'FULL OUTER JOIN'; + /* public */ const JOIN = 'JOIN'; + /* public */ const LEFT_JOIN = 'LEFT JOIN'; + /* public */ const LEFT_OUTER_JOIN = 'LEFT OUTER JOIN'; + /* public */ const LEFT_INNER_JOIN = 'LEFT INNER JOIN'; + /* public */ const RIGHT_JOIN = 'RIGHT JOIN'; + /* public */ const RIGHT_OUTER_JOIN = 'RIGHT OUTER JOIN'; + /* public */ const RIGHT_INNER_JOIN = 'RIGHT INNER JOIN'; + /* public */ const OUTER_JOIN = 'OUTER JOIN'; + /* public */ const INNER_JOIN = 'INNER JOIN'; + /* public */ const CROSS_JOIN = 'CROSS JOIN'; + /* public */ const FULL_OUTER_JOIN = 'FULL OUTER JOIN'; } diff --git a/DataStorage/Database/Query/QueryType.php b/DataStorage/Database/Query/QueryType.php index 6c6c373d0..c9a27b9f0 100644 --- a/DataStorage/Database/Query/QueryType.php +++ b/DataStorage/Database/Query/QueryType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -30,10 +30,10 @@ use phpOMS\Datatypes\Enum; */ abstract class QueryType extends Enum { - const SELECT = 0; - const INSERT = 1; - const UPDATE = 2; - const DELETE = 3; - const RANDOM = 4; - const RAW = 5; + /* public */ const SELECT = 0; + /* public */ const INSERT = 1; + /* public */ const UPDATE = 2; + /* public */ const DELETE = 3; + /* public */ const RANDOM = 4; + /* public */ const RAW = 5; } diff --git a/DataStorage/Database/Query/Where.php b/DataStorage/Database/Query/Where.php index 2848b2fe4..f371753e9 100644 --- a/DataStorage/Database/Query/Where.php +++ b/DataStorage/Database/Query/Where.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/RelationType.php b/DataStorage/Database/RelationType.php index bf37831c7..361473b67 100644 --- a/DataStorage/Database/RelationType.php +++ b/DataStorage/Database/RelationType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -32,7 +32,7 @@ use phpOMS\Datatypes\Enum; */ abstract class RelationType extends Enum { - const NONE = 0; - const NEWEST = 1; - const ALL = 2; + /* public */ const NONE = 0; + /* public */ const NEWEST = 1; + /* public */ const ALL = 2; } diff --git a/DataStorage/Database/Schema/Builder.php b/DataStorage/Database/Schema/Builder.php index e1113a6b9..dbb7ee1bb 100644 --- a/DataStorage/Database/Schema/Builder.php +++ b/DataStorage/Database/Schema/Builder.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -51,7 +51,7 @@ class Builder extends BuilderAbstract $this->grammar = $connection->getSchemaGrammar(); } - public function select(...$table) + public function select(...$table) /* : void */ { $this->type = QueryType::SELECT; $this->table += $table; diff --git a/DataStorage/Database/Schema/Exception/TableException.php b/DataStorage/Database/Schema/Exception/TableException.php index de2d14a8e..1264d1ff9 100644 --- a/DataStorage/Database/Schema/Exception/TableException.php +++ b/DataStorage/Database/Schema/Exception/TableException.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Schema/Grammar/Grammar.php b/DataStorage/Database/Schema/Grammar/Grammar.php index 8db2ab858..b438e988a 100644 --- a/DataStorage/Database/Schema/Grammar/Grammar.php +++ b/DataStorage/Database/Schema/Grammar/Grammar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Schema/Grammar/GrammarInterface.php b/DataStorage/Database/Schema/Grammar/GrammarInterface.php index be21d0dbe..bded3ba6d 100644 --- a/DataStorage/Database/Schema/Grammar/GrammarInterface.php +++ b/DataStorage/Database/Schema/Grammar/GrammarInterface.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Schema/Grammar/MysqlGrammar.php b/DataStorage/Database/Schema/Grammar/MysqlGrammar.php index d7687a140..94885ca1e 100644 --- a/DataStorage/Database/Schema/Grammar/MysqlGrammar.php +++ b/DataStorage/Database/Schema/Grammar/MysqlGrammar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Schema/Grammar/PostgresGrammar.php b/DataStorage/Database/Schema/Grammar/PostgresGrammar.php index 47ee9f3f5..1ff46622e 100644 --- a/DataStorage/Database/Schema/Grammar/PostgresGrammar.php +++ b/DataStorage/Database/Schema/Grammar/PostgresGrammar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Schema/Grammar/SQLiteGrammar.php b/DataStorage/Database/Schema/Grammar/SQLiteGrammar.php index 4065b2295..7c369dce2 100644 --- a/DataStorage/Database/Schema/Grammar/SQLiteGrammar.php +++ b/DataStorage/Database/Schema/Grammar/SQLiteGrammar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Schema/Grammar/SqlServerGrammar.php b/DataStorage/Database/Schema/Grammar/SqlServerGrammar.php index c39775f1f..9bcc3db3d 100644 --- a/DataStorage/Database/Schema/Grammar/SqlServerGrammar.php +++ b/DataStorage/Database/Schema/Grammar/SqlServerGrammar.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Database/Schema/QueryType.php b/DataStorage/Database/Schema/QueryType.php index 2a72296f7..605c091a3 100644 --- a/DataStorage/Database/Schema/QueryType.php +++ b/DataStorage/Database/Schema/QueryType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -32,8 +32,8 @@ use phpOMS\Datatypes\Enum; */ abstract class QueryType extends Enum { - const SELECT = 0; - const CREATE = 1; - const DROP = 2; - const ALTER = 3; + /* public */ const SELECT = 0; + /* public */ const CREATE = 1; + /* public */ const DROP = 2; + /* public */ const ALTER = 3; } diff --git a/DataStorage/LockException.php b/DataStorage/LockException.php index a0dffcf53..ca6afd415 100644 --- a/DataStorage/LockException.php +++ b/DataStorage/LockException.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/DataStorage/Session/ConsoleSession.php b/DataStorage/Session/ConsoleSession.php index 088e25b82..4e8cd0b87 100644 --- a/DataStorage/Session/ConsoleSession.php +++ b/DataStorage/Session/ConsoleSession.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -84,7 +84,7 @@ class ConsoleSession implements SessionInterface /** * {@inheritdoc} */ - public function setSID($sid) + public function setSID($sid) /* : void */ { $this->sid = $sid; } diff --git a/DataStorage/Session/HttpSession.php b/DataStorage/Session/HttpSession.php index 926439333..791a400c5 100644 --- a/DataStorage/Session/HttpSession.php +++ b/DataStorage/Session/HttpSession.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -85,8 +85,6 @@ class HttpSession implements SessionInterface $this->sid = session_id(); $this->setCsrfProtection(); - - self::$isLocked = true; } /** @@ -95,7 +93,7 @@ class HttpSession implements SessionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - private function setCsrfProtection() + private function setCsrfProtection() /* : void */ { $this->set('UID', 0, false); @@ -129,12 +127,26 @@ class HttpSession implements SessionInterface return $this->sessionData[$key] ?? null; } - public static function lock() + /** + * Lock session from further adjustments. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function lock() { self::$isLocked = true; } - public static function isLocked() + /** + * Check if session is locked. + * + * @return bool Lock status + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function isLocked() : bool { return self::$isLocked; } @@ -142,9 +154,12 @@ class HttpSession implements SessionInterface /** * {@inheritdoc} */ - public function save() + public function save() /* : void */ { - + if(!self::$isLocked) { + $_SESSION = $this->sessionData; + session_write_close(); + } } /** @@ -172,15 +187,20 @@ class HttpSession implements SessionInterface /** * {@inheritdoc} */ - public function setSID($sid) + public function setSID($sid) /* : void */ { $this->sid = $sid; } + /** + * Destruct session. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __destruct() { - $_SESSION = $this->sessionData; - session_write_close(); + $this->save(); } } diff --git a/DataStorage/Session/SessionInterface.php b/DataStorage/Session/SessionInterface.php index 77a03f195..93c3ef2eb 100644 --- a/DataStorage/Session/SessionInterface.php +++ b/DataStorage/Session/SessionInterface.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -79,7 +79,7 @@ interface SessionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function save(); + public function save() /* : void */; /** * @return int|string @@ -97,6 +97,6 @@ interface SessionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setSID($sid); + public function setSID($sid) /* : void */; } diff --git a/DataStorage/Session/SocketSession.php b/DataStorage/Session/SocketSession.php index 0ae50a265..bbb1cedf6 100644 --- a/DataStorage/Session/SocketSession.php +++ b/DataStorage/Session/SocketSession.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -84,7 +84,7 @@ class SocketSession implements SessionInterface /** * {@inheritdoc} */ - public function setSID($sid) + public function setSID($sid) /* : void */ { $this->sid = $sid; } @@ -92,7 +92,7 @@ class SocketSession implements SessionInterface /** * {@inheritdoc} */ - public function save() + public function save() /* : void */ { } diff --git a/Datatypes/Address.php b/Datatypes/Address.php index 868651f12..5965b636f 100644 --- a/Datatypes/Address.php +++ b/Datatypes/Address.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -87,7 +87,7 @@ class Address implements \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setRecipient(string $recipient) + public function setRecipient(string $recipient) /* : void */ { $this->recipient = $recipient; } @@ -115,7 +115,7 @@ class Address implements \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setFAO(string $fao) + public function setFAO(string $fao) /* : void */ { $this->fao = $fao; } @@ -143,7 +143,7 @@ class Address implements \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setLocation(Location $location) + public function setLocation(Location $location) /* : void */ { $this->location = $location; } diff --git a/Datatypes/AddressType.php b/Datatypes/AddressType.php index 17541eb58..7716c9be3 100644 --- a/Datatypes/AddressType.php +++ b/Datatypes/AddressType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -28,9 +28,9 @@ namespace phpOMS\Datatypes; */ abstract class AddressType extends Enum { - const HOME = 1; - const BUSINESS = 2; - const SHIPPING = 3; - const BILLING = 4; - const WORK = 5; + /* public */ const HOME = 1; + /* public */ const BUSINESS = 2; + /* public */ const SHIPPING = 3; + /* public */ const BILLING = 4; + /* public */ const WORK = 5; } diff --git a/Datatypes/Enum.php b/Datatypes/Enum.php index 5f7a0a8d1..20fc8833b 100644 --- a/Datatypes/Enum.php +++ b/Datatypes/Enum.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Datatypes/EnumArray.php b/Datatypes/EnumArray.php index 407b61b67..9eb9a3732 100644 --- a/Datatypes/EnumArray.php +++ b/Datatypes/EnumArray.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Datatypes/ExactFloat.php b/Datatypes/ExactFloat.php index 41aa4efc3..e2167fc0b 100644 --- a/Datatypes/ExactFloat.php +++ b/Datatypes/ExactFloat.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -20,7 +20,7 @@ class ExactFloat private static $length = 0; - public static function setLength($length) + public static function setLength($length) /* : void */ { self::$length = (int) $length; } diff --git a/Datatypes/Exception/InvalidEnumName.php b/Datatypes/Exception/InvalidEnumName.php index 01082e807..a9475c394 100644 --- a/Datatypes/Exception/InvalidEnumName.php +++ b/Datatypes/Exception/InvalidEnumName.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Datatypes/Exception/InvalidEnumValue.php b/Datatypes/Exception/InvalidEnumValue.php index 79a50674e..335b5b325 100644 --- a/Datatypes/Exception/InvalidEnumValue.php +++ b/Datatypes/Exception/InvalidEnumValue.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Datatypes/Iban.php b/Datatypes/Iban.php index 1d529a752..320ca39cb 100644 --- a/Datatypes/Iban.php +++ b/Datatypes/Iban.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -63,7 +63,7 @@ class Iban implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - private function parse(string $iban) + private function parse(string $iban) /* : void */ { $this->iban = self::normalize($iban); diff --git a/Datatypes/Location.php b/Datatypes/Location.php index aa40936aa..3b93d3c11 100644 --- a/Datatypes/Location.php +++ b/Datatypes/Location.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -106,7 +106,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setPostal(string $postal) + public function setPostal(string $postal) /* : void */ { $this->postal = $postal; } @@ -130,7 +130,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCity(string $city) + public function setCity(string $city) /* : void */ { $this->city = $city; } @@ -154,7 +154,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCountry(string $country) + public function setCountry(string $country) /* : void */ { $this->country = $country; } @@ -178,7 +178,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setAddress(string $address) + public function setAddress(string $address) /* : void */ { $this->address = $address; } @@ -202,7 +202,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setState(string $state) + public function setState(string $state) /* : void */ { $this->state = $state; } @@ -226,7 +226,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setGeo(array $geo) + public function setGeo(array $geo) /* : void */ { $this->geo = $geo; } diff --git a/Datatypes/NullLocation.php b/Datatypes/NullLocation.php index 59a2ab502..f17b9358c 100644 --- a/Datatypes/NullLocation.php +++ b/Datatypes/NullLocation.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Datatypes/PhoneType.php b/Datatypes/PhoneType.php index e505d07bb..8f1b3aef1 100644 --- a/Datatypes/PhoneType.php +++ b/Datatypes/PhoneType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -28,8 +28,8 @@ namespace phpOMS\Datatypes; */ abstract class PhoneType extends Enum { - const HOME = 1; - const BUSINESS = 2; - const MOBILE = 3; - const WORK = 4; + /* public */ const HOME = 1; + /* public */ const BUSINESS = 2; + /* public */ const MOBILE = 3; + /* public */ const WORK = 4; } diff --git a/Datatypes/SmartDateTime.php b/Datatypes/SmartDateTime.php index ada93ae30..815bac57d 100644 --- a/Datatypes/SmartDateTime.php +++ b/Datatypes/SmartDateTime.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -36,7 +36,7 @@ class SmartDateTime extends \DateTime * @var string * @since 1.0.0 */ - const FORMAT = 'Y-m-d hh:mm:ss'; + /* public */ const FORMAT = 'Y-m-d hh:mm:ss'; /** * Default timezone @@ -44,7 +44,7 @@ class SmartDateTime extends \DateTime * @var string * @since 1.0.0 */ - const TIMEZONE = 'UTC'; + /* public */ const TIMEZONE = 'UTC'; /** * {@inheritdoc} @@ -90,7 +90,7 @@ class SmartDateTime extends \DateTime */ public function smartModify(int $y, int $m = 0, int $d = 0, int $calendar = CAL_GREGORIAN) : SmartDateTime { - $y_change = floor(((int) $this->format('m') - 1 + $m) / 12); + $y_change = (int) floor(((int) $this->format('m') - 1 + $m) / 12); $y_change = ((int) $this->format('m') - 1 + $m) < 0 && ((int) $this->format('m') - 1 + $m) % 12 === 0 ? $y_change - 1 : $y_change; $y_new = (int) $this->format('Y') + $y + $y_change; $m_new = ((int) $this->format('m') + $m) % 12; diff --git a/Dispatcher/Dispatcher.php b/Dispatcher/Dispatcher.php index ec4e874d0..ba57ea67d 100644 --- a/Dispatcher/Dispatcher.php +++ b/Dispatcher/Dispatcher.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Event/EventManager.php b/Event/EventManager.php index be7446beb..4ecc0e40e 100644 --- a/Event/EventManager.php +++ b/Event/EventManager.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -75,7 +75,7 @@ class EventManager implements Mediator /** * {@inheritdoc} */ - public function trigger(string $group, string $id = '') + public function trigger(string $group, string $id = '', bool $reset = false) /* : void */ { if (isset($this->groups[$group])) { unset($this->groups[$group][$id]); @@ -117,7 +117,7 @@ class EventManager implements Mediator /** * {@inheritdoc} */ - public function addGroup(string $group, string $id) + public function addGroup(string $group, string $id) /* : void */ { if (!isset($this->groups[$group])) { $this->groups[$group] = []; diff --git a/Html/TagType.php b/Html/TagType.php index cd8263136..a75403038 100644 --- a/Html/TagType.php +++ b/Html/TagType.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD @@ -30,13 +30,13 @@ use phpOMS\Datatypes\Enum; */ abstract class TagType extends Enum { - const INPUT = 0; /* */ - const BUTTON = 1; /*