diff --git a/Account/Account.php b/Account/Account.php index ed5518e44..bd058a2bc 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -23,7 +23,7 @@ use phpOMS\Validation\Base\Email; * Account manager class. * * @category Framework - * @package phpOMS\Asset + * @package phpOMS\Account * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Account/AccountManager.php b/Account/AccountManager.php index 58adcd736..ec478dc7e 100644 --- a/Account/AccountManager.php +++ b/Account/AccountManager.php @@ -19,7 +19,7 @@ namespace phpOMS\Account; * Account manager class. * * @category Framework - * @package phpOMS\Asset + * @package phpOMS\Account * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Account/AccountStatus.php b/Account/AccountStatus.php index 2e1c024e4..4dd1b2ee2 100644 --- a/Account/AccountStatus.php +++ b/Account/AccountStatus.php @@ -18,10 +18,10 @@ namespace phpOMS\Account; use phpOMS\Datatypes\Enum; /** - * Account type enum. + * Account status enum. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Account * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Account/Group.php b/Account/Group.php index d2e90ad15..85f881bcd 100644 --- a/Account/Group.php +++ b/Account/Group.php @@ -19,7 +19,7 @@ namespace phpOMS\Account; * Account group class. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Account * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Account/NullAccount.php b/Account/NullAccount.php index d389f42dc..1feea9cf7 100644 --- a/Account/NullAccount.php +++ b/Account/NullAccount.php @@ -19,7 +19,7 @@ namespace phpOMS\Account; * Null account class. * * @category Framework - * @package phpOMS\Asset + * @package phpOMS\Account * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Asset/AssetManager.php b/Asset/AssetManager.php index 1e2389866..c5108af37 100644 --- a/Asset/AssetManager.php +++ b/Asset/AssetManager.php @@ -18,8 +18,6 @@ namespace phpOMS\Asset; /** * Asset manager class. * - * Responsible for authenticating and initializing the connection - * * @category Framework * @package phpOMS\Asset * @author OMS Development Team diff --git a/Asset/AssetType.php b/Asset/AssetType.php index 27f5e302b..4b8a543db 100644 --- a/Asset/AssetType.php +++ b/Asset/AssetType.php @@ -18,12 +18,10 @@ namespace phpOMS\Asset; use phpOMS\Datatypes\Enum; /** - * Login return types enum. - * - * These are possible answers to authentications. + * Asset types enum. * * @category Framework - * @package phpOMS\Auth + * @package phpOMS\Asset * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Autoloader.php b/Autoloader.php index 6907dfad7..ca3e32ca2 100644 --- a/Autoloader.php +++ b/Autoloader.php @@ -46,9 +46,9 @@ class Autoloader */ public static function default_autoloader(string $class) { - if (($class = self::exists($class)) !== false) { + if (($classNew = self::exists($class)) !== false) { /** @noinspection PhpIncludeInspection */ - include __DIR__ . '/../' . $class . '.php'; + include __DIR__ . '/../' . $classNew . '.php'; } else { throw new \Exception($class); } diff --git a/DataStorage/Database/DatabaseExceptionFactory.php b/DataStorage/Database/DatabaseExceptionFactory.php index 1524f84b2..fc46ee28e 100644 --- a/DataStorage/Database/DatabaseExceptionFactory.php +++ b/DataStorage/Database/DatabaseExceptionFactory.php @@ -18,10 +18,10 @@ namespace phpOMS\DataStorage\Database; use phpOMS\DataStorage\Database\Schema\Exception\TableException; /** - * Path exception class. + * Database exception factory. * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\DataStorage\Database * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 @@ -33,9 +33,9 @@ class DatabaseExceptionFactory /** * Constructor. * - * @param string $message Exception message - * @param int $code Exception code - * @param \Exception Previous exception + * @param \PDOException $e Exception + * + * @return \PDOException * * @since 1.0.0 * @author Dennis Eichhorn @@ -50,6 +50,16 @@ class DatabaseExceptionFactory } } + /** + * Create table exception. + * + * @param \PDOException $e Exception + * + * @return \PDOException + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private static function createTableViewException(\PDOException $e) : \PDOException { return new TableException(TableException::findTable($e->getMessage())); diff --git a/DataStorage/Database/GrammarAbstract.php b/DataStorage/Database/GrammarAbstract.php index f9177248d..0092be031 100644 --- a/DataStorage/Database/GrammarAbstract.php +++ b/DataStorage/Database/GrammarAbstract.php @@ -16,6 +16,17 @@ namespace phpOMS\DataStorage\Database; +/** + * Grammar. + * + * @category Framework + * @package phpOMS\DataStorage\Database + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ abstract class GrammarAbstract { /** diff --git a/Datatypes/AddressType.php b/Datatypes/AddressType.php index 76ef3334c..4fd246ece 100644 --- a/Datatypes/AddressType.php +++ b/Datatypes/AddressType.php @@ -19,7 +19,7 @@ namespace phpOMS\Datatypes; * Address type enum. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Datatypes * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Datatypes/Exception/InvalidEnumName.php b/Datatypes/Exception/InvalidEnumName.php index 67835071b..01082e807 100644 --- a/Datatypes/Exception/InvalidEnumName.php +++ b/Datatypes/Exception/InvalidEnumName.php @@ -20,8 +20,8 @@ namespace phpOMS\Datatypes\Exception; * * Performing operations on the file system * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\Datatypes * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Datatypes/Exception/InvalidEnumValue.php b/Datatypes/Exception/InvalidEnumValue.php index 2ecebed96..79a50674e 100644 --- a/Datatypes/Exception/InvalidEnumValue.php +++ b/Datatypes/Exception/InvalidEnumValue.php @@ -20,8 +20,8 @@ namespace phpOMS\Datatypes\Exception; * * Performing operations on the file system * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\Datatypes * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Datatypes/PhoneType.php b/Datatypes/PhoneType.php index 279718947..fec760821 100644 --- a/Datatypes/PhoneType.php +++ b/Datatypes/PhoneType.php @@ -19,7 +19,7 @@ namespace phpOMS\Datatypes; * Address type enum. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Datatypes * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Datatypes/SmartDateTime.php b/Datatypes/SmartDateTime.php index df337487e..b2505f9d4 100644 --- a/Datatypes/SmartDateTime.php +++ b/Datatypes/SmartDateTime.php @@ -20,7 +20,7 @@ namespace phpOMS\Datatypes; * * Providing smarter datetimes * - * @category Modules + * @category Framework * @package phpOMS\Datatypes * @author OMS Development Team * @author Dennis Eichhorn diff --git a/Dispatcher/ConsoleDispatcher.php b/Dispatcher/ConsoleDispatcher.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/Dispatcher/Dispatcher.php b/Dispatcher/Dispatcher.php index dd113d76b..c13114a15 100644 --- a/Dispatcher/Dispatcher.php +++ b/Dispatcher/Dispatcher.php @@ -26,7 +26,7 @@ use phpOMS\Views\ViewLayout; * Dispatcher class. * * @category Framework - * @package Framework + * @package phpOMS\Dispatcher * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 @@ -102,7 +102,20 @@ class Dispatcher return $views; } - private function dispatchString(string $controller, RequestAbstract $request, ResponseAbstract $response, $data = null) + /** + * Dispatch string. + * + * @param string|array|\Closure $controller Controller string + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Data + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + private function dispatchString(string $controller, RequestAbstract $request, ResponseAbstract $response, $data = null) : array { $views =[]; $dispatch = explode(':', $controller); @@ -120,6 +133,19 @@ class Dispatcher return $views; } + /** + * Dispatch array. + * + * @param string|array|\Closure $controller Controller string + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Data + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function dispatchArray(array $controller, RequestAbstract $request, ResponseAbstract $response, $data = null) : array { $views = []; @@ -132,11 +158,34 @@ class Dispatcher return $views; } + /** + * Dispatch closure. + * + * @param string|array|\Closure $controller Controller string + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Data + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function dispatchClosure(\Closure $controller, RequestAbstract $request, ResponseAbstract $response, $data = null) { return $controller($this->app, $request, $response, $data); } + /** + * Dispatch controller. + * + * @param string $controller Controller + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function getController(string $controller) { if (!isset($this->controllers[$controller])) { diff --git a/Dispatcher/DispatcherInterface.php b/Dispatcher/DispatcherInterface.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/Dispatcher/HttpDispatcher.php b/Dispatcher/HttpDispatcher.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/Dispatcher/LocalDispatcher.php b/Dispatcher/LocalDispatcher.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/Dispatcher/SocketDispatcher.php b/Dispatcher/SocketDispatcher.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/Event/EventManager.php b/Event/EventManager.php index a25f9a3d1..631454d6c 100644 --- a/Event/EventManager.php +++ b/Event/EventManager.php @@ -18,10 +18,14 @@ namespace phpOMS\Event; use phpOMS\Pattern\Mediator; /** - * EventManager class. + * Dispatcher class. * * @category Framework * @package phpOMS\Event + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com * @since 1.0.0 * * @todo : make cachable + database storable -> can reload user defined listeners (persistent events) diff --git a/Localization/CityGeoLocationsEnumArray.php b/Localization/CityGeoLocationsEnumArray.php index 15657574a..72a5a11ab 100644 --- a/Localization/CityGeoLocationsEnumArray.php +++ b/Localization/CityGeoLocationsEnumArray.php @@ -1,13 +1,17 @@ + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com */ namespace phpOMS\Localization; @@ -15,7 +19,7 @@ namespace phpOMS\Localization; * Cities and geo locations * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO3166CharEnum.php b/Localization/ISO3166CharEnum.php index 00bab0b20..a2333f3e8 100644 --- a/Localization/ISO3166CharEnum.php +++ b/Localization/ISO3166CharEnum.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\EnumArray; * Country codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO3166Enum.php b/Localization/ISO3166Enum.php index f2d5ad6cf..fa208e595 100644 --- a/Localization/ISO3166Enum.php +++ b/Localization/ISO3166Enum.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum; * Country codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO3166EnumArray.php b/Localization/ISO3166EnumArray.php index 4039135f0..059039c0f 100644 --- a/Localization/ISO3166EnumArray.php +++ b/Localization/ISO3166EnumArray.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\EnumArray; * Country codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO3166NameEnum.php b/Localization/ISO3166NameEnum.php index f83981e8a..18a50297a 100644 --- a/Localization/ISO3166NameEnum.php +++ b/Localization/ISO3166NameEnum.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum; * Country codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO3166NumEnum.php b/Localization/ISO3166NumEnum.php index 26102a85d..227705966 100644 --- a/Localization/ISO3166NumEnum.php +++ b/Localization/ISO3166NumEnum.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum; * Country codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO3166TwoEnum.php b/Localization/ISO3166TwoEnum.php index 9ce357a4d..6adc70894 100644 --- a/Localization/ISO3166TwoEnum.php +++ b/Localization/ISO3166TwoEnum.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\EnumArray; * Country codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO4217CharEnum.php b/Localization/ISO4217CharEnum.php index 95ff3cb6e..d4fa5d2bf 100644 --- a/Localization/ISO4217CharEnum.php +++ b/Localization/ISO4217CharEnum.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum; * Country codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO4217DecimalEnum.php b/Localization/ISO4217DecimalEnum.php index 923a16456..38190a0b8 100644 --- a/Localization/ISO4217DecimalEnum.php +++ b/Localization/ISO4217DecimalEnum.php @@ -22,7 +22,7 @@ use phpOMS\Datatypes\Enum; * Country codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO4217Enum.php b/Localization/ISO4217Enum.php index 646ac56f4..c33a774e0 100644 --- a/Localization/ISO4217Enum.php +++ b/Localization/ISO4217Enum.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum; * Country codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO4217EnumArray.php b/Localization/ISO4217EnumArray.php index e13e31ab0..e163a1dfa 100644 --- a/Localization/ISO4217EnumArray.php +++ b/Localization/ISO4217EnumArray.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\EnumArray; * Currency codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO4217NumEnum.php b/Localization/ISO4217NumEnum.php index 6a09d0902..6a6a4db9e 100644 --- a/Localization/ISO4217NumEnum.php +++ b/Localization/ISO4217NumEnum.php @@ -22,7 +22,7 @@ use phpOMS\Datatypes\Enum; * Country codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO4217SymbolEnum.php b/Localization/ISO4217SymbolEnum.php index 48dec08c1..082f09ef7 100644 --- a/Localization/ISO4217SymbolEnum.php +++ b/Localization/ISO4217SymbolEnum.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum; * Country symbols ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO639Enum.php b/Localization/ISO639Enum.php index 667b284e1..d9ba081c3 100644 --- a/Localization/ISO639Enum.php +++ b/Localization/ISO639Enum.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum; * Language codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO639EnumArray.php b/Localization/ISO639EnumArray.php index e2657f50e..2e79475af 100644 --- a/Localization/ISO639EnumArray.php +++ b/Localization/ISO639EnumArray.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\EnumArray; * Language codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO639x1Enum.php b/Localization/ISO639x1Enum.php index cb80ea301..df897b8f0 100644 --- a/Localization/ISO639x1Enum.php +++ b/Localization/ISO639x1Enum.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum; * Language codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/ISO8601EnumArray.php b/Localization/ISO8601EnumArray.php index 529ca5a04..8c7524442 100644 --- a/Localization/ISO8601EnumArray.php +++ b/Localization/ISO8601EnumArray.php @@ -24,7 +24,7 @@ use phpOMS\Datatypes\EnumArray; * contain all plausible datetime strings. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/Money.php b/Localization/Money.php index 0fcd7389e..562f0e6e3 100644 --- a/Localization/Money.php +++ b/Localization/Money.php @@ -1,17 +1,84 @@ + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ namespace phpOMS\Localization; -class Money implements Serialize { +/** + * Money class. + * + * @category Framework + * @package phpOMS\Localization + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Money implements \Serializable +{ + /** + * Max amount of decimals. + * + * @var int + * @since 1.0.0 + */ const MAX_DECIMALS = 5; + /** + * Currency symbol. + * + * @var string + * @since 1.0.0 + */ private $currency = ISO4217CharEnum::C_USD; + + /** + * Thousands separator. + * + * @var string + * @since 1.0.0 + */ private $thousands = ','; + + /** + * Decimal separator. + * + * @var string + * @since 1.0.0 + */ private $decimal = '.'; + /** + * Value. + * + * @var int + * @since 1.0.0 + */ private $value = 0; + /** + * Constructor. + * + * @param string $currency Currency symbol + * @param string $thousands Thousands separator + * @param string $decimal Decimal separator + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __construct(string $currency = ISO4217CharEnum::C_USD, string $thousands = ',', string $decimal = '.') { $this->currency = $currency; @@ -19,18 +86,60 @@ class Money implements Serialize { $this->decimal = $decimal; } - public function setInt(int $value) { + /** + * Set money value. + * + * @param int $value Value + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setInt(int $value) + { $this->value = $value; } - public function getInt() : int { + /** + * Get money value. + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getInt() : int + { return $this->value; } - public function setString(string $value) { + /** + * Set value by string. + * + * @param string $value Money value + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setString(string $value) + { $this->value = self::toInt($value, $this->decimal); } + /** + * Money to int. + * + * @param string $value Money value + * @param string $decimal Decimal character + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public static function toInt(string $value, string $decimal = ',') : int { $split = explode($value, $decimal); @@ -48,6 +157,16 @@ class Money implements Serialize { $this->value = (int) $left * 100000 + (int) $right; } + /** + * Get money. + * + * @param int $decimals Precision + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getAmount(int $decimals = 2) : string { if($decimals > ($dec = ISO4217DecimalEnum::${'C_' . strtoupper($this->currency)})) { @@ -62,6 +181,16 @@ class Money implements Serialize { return ($decimals > 0) : number_format($left, 0, $this->thousands, $this->decimal); . $this->decimal . $right : (string) $left; } + /** + * Add money. + * + * @param Money|string|int|float $value + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function add($value) { if(is_string($value) || is_float($value)) { @@ -73,6 +202,16 @@ class Money implements Serialize { } } + /** + * Sub money. + * + * @param Money|string|int|float $value + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function sub($value) { if(is_string($value) || is_float($value)) { @@ -84,6 +223,16 @@ class Money implements Serialize { } } + /** + * Mult. + * + * @param int|float $value + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function mult($value) { if(is_float($value) || is_int($value)) { @@ -91,6 +240,16 @@ class Money implements Serialize { } } + /** + * Div. + * + * @param int|float $value + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function div($value) { if(is_float($value) || is_int($value)) { @@ -98,12 +257,30 @@ class Money implements Serialize { } } - public function serialize() : int + /** + * Searialze. + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function serialize() { return $this->getInt(); } - public function unserialize(int $value) + /** + * Unserialize. + * + * @param mixed $value + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function unserialize($value) { $this->setInt($value); } diff --git a/Localization/NullLocalization.php b/Localization/NullLocalization.php index 532d12c19..733563cab 100644 --- a/Localization/NullLocalization.php +++ b/Localization/NullLocalization.php @@ -15,8 +15,6 @@ */ namespace phpOMS\Localization; - - /** * Localization class. * diff --git a/Localization/PhoneEnum.php b/Localization/PhoneEnum.php index 8a1b0e857..b04ca1820 100644 --- a/Localization/PhoneEnum.php +++ b/Localization/PhoneEnum.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum; * Country codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/PhoneEnumArray.php b/Localization/PhoneEnumArray.php index 87fbf7788..d3d10bf7d 100644 --- a/Localization/PhoneEnumArray.php +++ b/Localization/PhoneEnumArray.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\EnumArray; * Currency codes ISO list. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Localization/TimeZoneEnumArray.php b/Localization/TimeZoneEnumArray.php index 5a373d8ef..7cab19b58 100644 --- a/Localization/TimeZoneEnumArray.php +++ b/Localization/TimeZoneEnumArray.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\EnumArray; * PHP Time zones. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Localization * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Log/LogLevel.php b/Log/LogLevel.php index 1b3e1b34c..db5cf2c2b 100644 --- a/Log/LogLevel.php +++ b/Log/LogLevel.php @@ -20,8 +20,8 @@ use phpOMS\Datatypes\Enum; /** * Log level enum. * - * @category Log - * @package Framework + * @category Framework + * @package phpOMS\Log * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Log/LoggerInterface.php b/Log/LoggerInterface.php index 1bae8ff51..cd3803140 100644 --- a/Log/LoggerInterface.php +++ b/Log/LoggerInterface.php @@ -15,6 +15,17 @@ */ namespace phpOMS\Log; +/** + * Logging interface. + * + * @category Framework + * @package phpOMS\Log + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ interface LoggerInterface { diff --git a/Message/Http/Header.php b/Message/Http/Header.php index 0ca37694e..1d225aadf 100644 --- a/Message/Http/Header.php +++ b/Message/Http/Header.php @@ -44,9 +44,17 @@ class Header extends HeaderAbstract public function __constrct() { - $this->setHeader('Content-Type', 'text/html; charset=utf-8'); + $this->set('Content-Type', 'text/html; charset=utf-8'); } + /** + * Returns all headers. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getHeaders() : array { return getallheaders(); @@ -146,6 +154,14 @@ class Header extends HeaderAbstract $this->lock(); } + /** + * Lock other header pushing models. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function lock() { CookieJar::lock(); @@ -173,6 +189,9 @@ class Header extends HeaderAbstract $this->generate406(); break; case RequestStatus::R_407: + $this->generate407(); + break; + case RequestStatus::R_503: $this->generate503(); break; default: @@ -180,22 +199,59 @@ class Header extends HeaderAbstract } } + /** + * Generate predefined header. + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function generate403() { - $this->setHeader('HTTP', 'HTTP/1.0 403 Forbidden'); - $this->setHeader('Status', 'Status: HTTP/1.0 403 Forbidden'); + $this->set('HTTP', 'HTTP/1.0 403 Forbidden'); + $this->set('Status', 'Status: HTTP/1.0 403 Forbidden'); } + /** + * Generate predefined header. + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function generate406() { - $this->setHeader('HTTP', 'HTTP/1.0 406 Not acceptable'); - $this->setHeader('Status', 'Status: 406 Not acceptable'); + $this->set('HTTP', 'HTTP/1.0 406 Not acceptable'); + $this->set('Status', 'Status: 406 Not acceptable'); } + /** + * Generate predefined header. + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function generate503() { - $this->setHeader('HTTP', 'HTTP/1.0 503 Service Temporarily Unavailable'); - $this->setHeader('Status', 'Status: 503 Service Temporarily Unavailable'); - $this->setHeader('Retry-After', 'Retry-After: 300'); + $this->set('HTTP', 'HTTP/1.0 503 Service Temporarily Unavailable'); + $this->set('Status', 'Status: 503 Service Temporarily Unavailable'); + $this->set('Retry-After', 'Retry-After: 300'); + } + + /** + * Generate predefined header. + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + private function generate407() + { + } } \ No newline at end of file diff --git a/Message/Http/Request.php b/Message/Http/Request.php index 629f9a8c6..1e17ac6be 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -60,6 +60,14 @@ class Request extends RequestAbstract */ protected $path = null; + /** + * Request status. + * + * @var string + * @since 1.0.0 + */ + protected $status = RequestStatus::R_200; + /** * Uploaded files. * @@ -431,6 +439,14 @@ class Request extends RequestAbstract return $this->files; } + /** + * Get route verb for this request. + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getRouteVerb() : int { switch($this->getMethod()) { diff --git a/Message/RequestStatus.php b/Message/Http/RequestStatus.php similarity index 98% rename from Message/RequestStatus.php rename to Message/Http/RequestStatus.php index d8de79c5f..9a4344650 100644 --- a/Message/RequestStatus.php +++ b/Message/Http/RequestStatus.php @@ -13,7 +13,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -namespace phpOMS\Message; +namespace phpOMS\Message\Http; use phpOMS\Datatypes\Enum; diff --git a/Message/Http/Response.php b/Message/Http/Response.php index 752937651..b0b8d63cd 100644 --- a/Message/Http/Response.php +++ b/Message/Http/Response.php @@ -120,7 +120,7 @@ class Response extends ResponseAbstract implements RenderableInterface } /** - * Generate response. + * Generate response based on header. * * @return string * @@ -139,11 +139,27 @@ class Response extends ResponseAbstract implements RenderableInterface } } + /** + * Generate json response. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function getJson() : string { return json_encode($this->getArray()); } + /** + * Generate raw response. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function getRaw() : string { $render = ''; @@ -165,6 +181,14 @@ class Response extends ResponseAbstract implements RenderableInterface return $render; } + /** + * Generate response array from views. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function getArray() : array { $result = []; diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index a59e9d70b..ef67340d5 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -112,7 +112,7 @@ abstract class RequestAbstract implements MessageInterface * @var string * @since 1.0.0 */ - private $status = RequestStatus::R_200; + protected $status = null; /** * Request hash. diff --git a/Message/ResponseAbstract.php b/Message/ResponseAbstract.php index 4c1ecb88b..78b9583e1 100644 --- a/Message/ResponseAbstract.php +++ b/Message/ResponseAbstract.php @@ -156,6 +156,14 @@ abstract class ResponseAbstract implements MessageInterface return json_encode($this->toArray()); } + /** + * Get header. + * + * @return HeaderAbstract + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getHeader() : HeaderAbstract { return $this->header; diff --git a/Model/Html/Head.php b/Model/Html/Head.php index 2a89e331a..ccc02840b 100644 --- a/Model/Html/Head.php +++ b/Model/Html/Head.php @@ -24,8 +24,8 @@ use phpOMS\Contract\RenderableInterface; * * Responsible for handling everything that's going on in the * - * @category Log - * @package Framework + * @category Framework + * @package phpOMS/Model * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Model/Html/Meta.php b/Model/Html/Meta.php index ead989119..07951c55e 100644 --- a/Model/Html/Meta.php +++ b/Model/Html/Meta.php @@ -20,8 +20,8 @@ use phpOMS\Contract\RenderableInterface; /** * Meta class. * - * @category Log - * @package Framework + * @category Framework + * @package phpOMS/Model * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Module/InfoManager.php b/Module/InfoManager.php index 343491d2a..aed29e840 100644 --- a/Module/InfoManager.php +++ b/Module/InfoManager.php @@ -24,8 +24,8 @@ use phpOMS\Validation\Validator; * * Handling the info files for modules * - * @category Module - * @package Framework + * @category Framework + * @package phpOMS\Module * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 @@ -64,6 +64,14 @@ class InfoManager $this->path = $path; } + /** + * Load info data from path. + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function load() { if (($path = realpath($this->path)) === false) { @@ -116,31 +124,79 @@ class InfoManager return $this->info; } + /** + * Get info data. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getInternalName() : string { return $this->info['name']['internal']; } + /** + * Get info data. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getDependencies() : array { return $this->info['dependencies']; } + /** + * Get info data. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getProviding() : array { return $this->info['providing']; } + /** + * Get info data. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getDirectory() : string { return $this->info['directory']; } + /** + * Get info data. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getVersion() : string { return $this->info['version']; } + /** + * Get info data. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getLoad() : array { return $this->info['load']; diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index 8fb39a65e..367334ffd 100644 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -52,17 +52,28 @@ class InstallerAbstract self::installRoutes(ROOT_PATH . '/Console/Routes.php', ROOT_PATH . '/Modules/' . $info->getDirectory() . '/Admin/Routes/console.php'); } - private static function installRoutes(string $appRoutePath, string $moduleRoutePath) + /** + * Install routes. + * + * @param string $destRoutePath Destination route path + * @param string $srcRoutePath Source route path + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + private static function installRoutes(string $destRoutePath, string $srcRoutePath) { - if(file_exists($appRoutePath) && file_exists($moduleRoutePath)) { - $appRoutes = include $appRoutePath; - $moduleRoutes = include $moduleRoutePath; + if(file_exists($destRoutePath) && file_exists($srcRoutePath)) { + $appRoutes = include $destRoutePath; + $moduleRoutes = include $srcRoutePath; $appRoutes = array_merge_recursive($appRoutes, $moduleRoutes); - if(is_writable($appRoutePath)) { - file_put_contents($appRoutePath, ' * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 011d2db84..cd18d8cf3 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -28,8 +28,8 @@ use phpOMS\Utils\IO\Json\InvalidJsonException; * * General module functionality such as listings and initialization. * - * @category Module - * @package Framework + * @category Framework + * @package phpOMS\Module * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 @@ -323,6 +323,16 @@ class ModuleManager } } + /** + * Register module in database. + * + * @param string $module Module name + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function registerInDatabase(InfoManager $info) { switch ($this->app->dbPool->get('core')->getType()) { @@ -366,6 +376,16 @@ class ModuleManager } } + /** + * Install module dependencies. + * + * @param array $dependencies Module dependencies + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function installDependencies(array $dependencies) { foreach ($dependencies as $key => $version) { @@ -373,6 +393,16 @@ class ModuleManager } } + /** + * Install module itself. + * + * @param InfoManager $info Module info + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function installModule(InfoManager $info) { $class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer'; @@ -385,6 +415,16 @@ class ModuleManager $class::install($this->app->dbPool, $info); } + /** + * Load info of module. + * + * @param string $module Module name + * + * @return InfoManager + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function loadInfo(string $module) : InfoManager { $path = realpath($oldPath = self::MODULE_PATH . '/' . $module . '/' . 'info.json'); @@ -465,6 +505,16 @@ class ModuleManager } } + /** + * Initialize array of modules. + * + * @param array $modules Modules + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function initModuleArray(array $modules) { foreach ($modules as $module) { @@ -480,6 +530,18 @@ class ModuleManager } } + /** + * Initialize module. + * + * Also registers controller in the dispatcher + * + * @param string $module Module + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function initModuleController(string $module) { $this->running[$module] = ModuleFactory::getInstance($module, $this->app); diff --git a/Router/ConsoleRoute.php b/Router/ConsoleRoute.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/Router/HttpRoute.php b/Router/HttpRoute.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/Router/RouteAbstract.php b/Router/RouteAbstract.php deleted file mode 100644 index 5eec48460..000000000 --- a/Router/RouteAbstract.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @author Dennis Eichhorn - * @copyright 2013 Dennis Eichhorn - * @license OMS License 1.0 - * @version 1.0.0 - * @link http://orange-management.com - */ -namespace phpOMS\Router; - -/** - * Router class. - * - * @category Framework - * @package phpOMS\Socket - * @author OMS Development Team - * @author Dennis Eichhorn - * @license OMS License 1.0 - * @link http://orange-management.com - * @since 1.0.0 - */ -class RouteAbstract -{ - - - -} \ No newline at end of file diff --git a/Router/RouteVerb.php b/Router/RouteVerb.php index 7fe08ddfb..16dd766bd 100644 --- a/Router/RouteVerb.php +++ b/Router/RouteVerb.php @@ -18,10 +18,10 @@ namespace phpOMS\Router; use phpOMS\Datatypes\Enum; /** - * View layout enum. + * Route verb enum. * * @category Framework - * @package phpOMS\Socket + * @package phpOMS\Router * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Router/Router.php b/Router/Router.php index 8723951ee..c17d8f98a 100644 --- a/Router/Router.php +++ b/Router/Router.php @@ -22,7 +22,7 @@ use phpOMS\Message\RequestAbstract; * Router class. * * @category Framework - * @package phpOMS\Socket + * @package phpOMS\Router * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 @@ -50,9 +50,19 @@ class Router { } + /** + * Add routes from file. + * + * @param string $path Route file path + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function importFromFile(string $path) { - $this->routes = include $path; + $this->routes += include $path; } /** @@ -61,7 +71,6 @@ class Router * @param string $route Route regex * @param mixed $destination Destination e.g. Module:function & verb * @param string $verb Request verb - * @param int $layout Result layout * * @return void * @@ -77,10 +86,9 @@ class Router } /** - * Route uri. + * Route request. * - * @param string $uri Uri to route - * @param string $verb GET/POST etc. + * @param RequestAbstract $request Request to route * * @return string[] * diff --git a/Router/SocketRoute.php b/Router/SocketRoute.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/Security/Encryption/Ceasar.php b/Security/Encryption/Ceasar.php deleted file mode 100644 index b3d9bbc7f..000000000 --- a/Security/Encryption/Ceasar.php +++ /dev/null @@ -1 +0,0 @@ - * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/MultiMap.php b/Stdlib/Map/MultiMap.php similarity index 99% rename from Utils/MultiMap.php rename to Stdlib/Map/MultiMap.php index a1ca38cdc..14555208e 100644 --- a/Utils/MultiMap.php +++ b/Stdlib/Map/MultiMap.php @@ -13,13 +13,13 @@ * @version 1.0.0 * @link http://orange-management.com */ -namespace phpOMS\Utils; +namespace phpOMS\Stdlib\Map; /** * Multimap utils. * * @category Framework - * @package Utils + * @package phpOMS\Stdlib * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/OrderType.php b/Stdlib/Map/OrderType.php similarity index 91% rename from Utils/OrderType.php rename to Stdlib/Map/OrderType.php index 455bf9127..b455b1634 100644 --- a/Utils/OrderType.php +++ b/Stdlib/Map/OrderType.php @@ -13,7 +13,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -namespace phpOMS\Utils; +namespace phpOMS\Stdlib\Map; use phpOMS\Datatypes\Enum; @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum; * Account type enum. * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Stdlib * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Stdlib/PriorityQueue.php b/Stdlib/Queue/PriorityQueue.php similarity index 93% rename from Stdlib/PriorityQueue.php rename to Stdlib/Queue/PriorityQueue.php index fa829c33d..f440eb5ab 100644 --- a/Stdlib/PriorityQueue.php +++ b/Stdlib/Queue/PriorityQueue.php @@ -13,13 +13,17 @@ * @version 1.0.0 * @link http://orange-management.com */ -namespace phpOMS\Stdlib; +namespace phpOMS\Stdlib\Queue; /** - * PriorityQueue class. + * Router class. * - * @category Stdlib - * @package Framework + * @category Framework + * @package phpOMS\Stdlib + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com * @since 1.0.0 */ class PriorityQueue implements \Countable, \Serializable diff --git a/System/File/Directory.php b/System/File/Directory.php index 62f66d96a..3925765ae 100644 --- a/System/File/Directory.php +++ b/System/File/Directory.php @@ -20,8 +20,8 @@ namespace phpOMS\System\File; * * Performing operations on the file system * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\System\File * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 @@ -46,6 +46,42 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess */ private $nodes = []; + /** + * Get folder size recursively. + * + * This can become rather slow for large structures. + * + * @param string $dir Root dir to inspect + * @param bool $recursive Get size recursive + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getFolderSize(string $dir, bool $recursive = true) : int + { + $countSize = 0; + $count = 0; + + if (is_readable($dir)) { + $dir_array = scandir($dir); + + foreach ($dir_array as $key => $filename) { + if ($filename != ".." && $filename != ".") { + if (is_dir($dir . "/" . $filename) && $recursive) { + $countSize += self::getFolderSize($dir . "/" . $filename, $recursive); + } else if (is_file($dir . "/" . $filename)) { + $countSize += filesize($dir . "/" . $filename); + $count++; + } + } + } + } + + return (int) $countSize; + } + /** * Get file count inside path. * diff --git a/System/File/File.php b/System/File/File.php index 4af2bd6d9..8abe87d9e 100644 --- a/System/File/File.php +++ b/System/File/File.php @@ -20,8 +20,8 @@ namespace phpOMS\System\File; * * Performing operations on the file system * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\System\File * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/System/File/FileAbstract.php b/System/File/FileAbstract.php index 88ce3f03f..5fe642ec8 100644 --- a/System/File/FileAbstract.php +++ b/System/File/FileAbstract.php @@ -20,8 +20,8 @@ namespace phpOMS\System\File; * * Performing operations on the file system * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\System\File * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/System/File/NullFile.php b/System/File/NullFile.php index d5c77feca..23e85128d 100644 --- a/System/File/NullFile.php +++ b/System/File/NullFile.php @@ -20,8 +20,8 @@ namespace phpOMS\System\File; * * Performing operations on the file system * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\System\File * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/System/File/PathException.php b/System/File/PathException.php index c50cecfcb..9e0cc9f1c 100644 --- a/System/File/PathException.php +++ b/System/File/PathException.php @@ -18,8 +18,8 @@ namespace phpOMS\System\File; /** * Path exception class. * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\System\File * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/System/File/PermissionException.php b/System/File/PermissionException.php index 14af15294..5d942a678 100644 --- a/System/File/PermissionException.php +++ b/System/File/PermissionException.php @@ -18,8 +18,8 @@ namespace phpOMS\System\File; /** * Permission exception class. * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\System\File * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/System/LockHandler.php b/System/LockHandler.php deleted file mode 100644 index e69de29bb..000000000 diff --git a/System/MimeType.php b/System/MimeType.php index 640cc4087..64ded39b2 100644 --- a/System/MimeType.php +++ b/System/MimeType.php @@ -23,7 +23,7 @@ use phpOMS\Datatypes\Enum; * Database types that are supported by the application * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\System * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/System/OperatingSystem.php b/System/OperatingSystem.php index 4b8243278..3950c14c0 100644 --- a/System/OperatingSystem.php +++ b/System/OperatingSystem.php @@ -18,8 +18,8 @@ namespace phpOMS\System; /** * Operating system class. * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\System * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/System/SystemType.php b/System/SystemType.php index ecdc4586a..9193c6417 100644 --- a/System/SystemType.php +++ b/System/SystemType.php @@ -23,7 +23,7 @@ use phpOMS\Datatypes\Enum; * Database types that are supported by the application * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\System * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/SystemUtils.php b/System/SystemUtils.php similarity index 72% rename from Utils/SystemUtils.php rename to System/SystemUtils.php index b563aa8ae..98523e98d 100644 --- a/Utils/SystemUtils.php +++ b/System/SystemUtils.php @@ -13,13 +13,13 @@ * @version 1.0.0 * @link http://orange-management.com */ -namespace phpOMS\Utils; +namespace phpOMS\System; /** * System utils * * @category Framework - * @package Utils + * @package phpOMS\System * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 @@ -39,41 +39,6 @@ class SystemUtils { } - /** - * Get folder size recursively. - * - * This can become rather slow for large structures. - * - * @param string $dir Root dir to inspect - * - * @return int - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - public static function getFolderSize(string $dir) : int - { - $countSize = 0; - $count = 0; - - if (is_readable($dir)) { - $dir_array = scandir($dir); - - foreach ($dir_array as $key => $filename) { - if ($filename != ".." && $filename != ".") { - if (is_dir($dir . "/" . $filename)) { - $countSize += self::getFolderSize($dir . "/" . $filename); - } else if (is_file($dir . "/" . $filename)) { - $countSize += filesize($dir . "/" . $filename); - $count++; - } - } - } - } - - return (int) $countSize; - } - /** * Get system RAM. * diff --git a/Uri/Http.php b/Uri/Http.php index 3fe8aee18..dd2fb33b4 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -20,8 +20,8 @@ namespace phpOMS\Uri; * * Used in order to create and evaluate a uri * - * @category Uri - * @package Framework + * @category Framework + * @package phpOMS/Uri * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Uri/InvalidUriException.php b/Uri/InvalidUriException.php index 117079e6f..bf4c13c3a 100644 --- a/Uri/InvalidUriException.php +++ b/Uri/InvalidUriException.php @@ -18,8 +18,8 @@ namespace phpOMS\Uri; /** * Uri exception. * - * @category Uri - * @package Framework + * @category Framework + * @package phpOMS/Uri * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 29dfd4e53..876bb57b8 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -20,8 +20,8 @@ namespace phpOMS\Uri; * * Used in order to create a uri * - * @category Uri - * @package Framework + * @category Framework + * @package phpOMS/Uri * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Uri/UriInterface.php b/Uri/UriInterface.php index f14e944d5..30596282e 100644 --- a/Uri/UriInterface.php +++ b/Uri/UriInterface.php @@ -18,8 +18,8 @@ namespace phpOMS\Uri; /** * Uri interface. * - * @category Uri - * @package Framework + * @category Framework + * @package phpOMS/Uri * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Uri/UriScheme.php b/Uri/UriScheme.php index 2a8fc6b98..98db08461 100644 --- a/Uri/UriScheme.php +++ b/Uri/UriScheme.php @@ -20,8 +20,8 @@ use phpOMS\Datatypes\Enum; /** * Uri scheme. * - * @category Uri - * @package Framework + * @category Framework + * @package phpOMS/Uri * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index ca2384d2b..c3c719188 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -19,7 +19,7 @@ namespace phpOMS\Utils; * Array utils. * * @category Framework - * @package Utils + * @package phpOMS\Utils * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Compiler/Php/ClassCompiler.php b/Utils/Compiler/Php/ClassCompiler.php deleted file mode 100644 index ff9957243..000000000 --- a/Utils/Compiler/Php/ClassCompiler.php +++ /dev/null @@ -1,170 +0,0 @@ - - * @author Dennis Eichhorn - * @copyright 2013 Dennis Eichhorn - * @license OMS License 1.0 - * @version 1.0.0 - * @link http://orange-management.com - */ -namespace phpOMS\Utils\Compiler\Php; - -use phpOMS\Utils\ArrayUtils; - -/** - * Php enum compiler. - * - * @category Framework - * @package phpOMS\DataStorage\Database - * @author OMS Development Team - * @author Dennis Eichhorn - * @license OMS License 1.0 - * @link http://orange-management.com - * @since 1.0.0 - */ -class ClassCompiler -{ - private $path = null; - - private $namespace = null; - - private $class = null; - - private $extends = null; - - private $implements = []; - - private $member = []; - - public function __construct($path) - { - $this->path = (string) $path; - } - - public function getPath() - { - return $this->path; - } - - public function setPath($path) - { - $this->path = (string) $path; - } - - public function setNamesapce($namespace) - { - $this->namespace = $namespace; - } - - public function getNamesapce() - { - return $this->namespace; - } - - public function getClass() - { - return $this->class; - } - - public function setClass($class) - { - $this->class = $class; - } - - public function getExtends() - { - return $this->extends; - } - - public function setExtends($extends) - { - $this->extends = $extends; - } - - public function addImplements($implements) - { - $this->implements[] = $implements; - } - - public function getImplements() - { - return $this->implements; - } - - public function getMember($name) - { - return $this->member[$name]; - } - - public function setMember($name, $default = null, $isString = false, $type = 'private', $static = false, $overwrite = true) - { - if ($overwrite || !isset($this->member[$name])) { - $this->member[$name] = ['default' => $default, - 'isString' => $isString, - 'type' => $type, - 'static' => $static,]; - } - } - - public function removeMember($name) - { - unset($this->member[$name]); - } - - public function __toString() - { - $member = ''; - foreach ($this->member as $name => $value) { - $member .= ' ' . ($value['static'] ? 'static ' : '') - . $value['type'] . ' ' . $name; - - if (isset($value['default'])) { - $member .= ' = '; - - if ($value['isString']) { - $member .= $value['default']; - } else { - switch (gettype($value['default'])) { - case 'array': - $member .= ArrayUtils::stringify($value['default']); - break; - case 'integer': - case 'float': - case 'double': - $member .= $value['default']; - break; - case 'string': - $member .= '"' . $value['default'] . '"'; - break; - case 'object': - $member .= get_class($value['default']) . '()'; - // TODO: implement object with parameters -> Reflection - break; - case 'boolean': - $member .= ($value['default'] ? 'true' : 'false'); - break; - case 'NULL': - $member .= 'null'; - break; - default: - throw new \Exception('Unknown default type'); - } - } - } - - $member .= ';' . PHP_EOL; - } - - return 'namespace) ? 'namespace ' . $this->namespace . ';' . PHP_EOL : '') - . 'abstract class' . $this->class . (isset($this->extends) ? ' extends ' . $this->extends : '') . (isset($this->implements) ? ' implements ' . implode(',', $this->implements) : '') . ' {' . PHP_EOL - . $member - . '}'; - } -} diff --git a/Utils/Converter/Currency.php b/Utils/Converter/Currency.php index 68824de1d..93aa675d3 100644 --- a/Utils/Converter/Currency.php +++ b/Utils/Converter/Currency.php @@ -19,7 +19,7 @@ namespace phpOMS\Utils\Converter; * Currency converter. * * @category Framework - * @package Converter + * @package phpOMS\Utils\Converter * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Converter/File.php b/Utils/Converter/File.php index 886ea6b8b..72895456c 100644 --- a/Utils/Converter/File.php +++ b/Utils/Converter/File.php @@ -19,7 +19,7 @@ namespace phpOMS\Utils\Converter; * File converter. * * @category Framework - * @package Converter + * @package phpOMS\Utils\Converter * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Converter/Measurement.php b/Utils/Converter/Measurement.php index fc5a641a7..e9d559c1f 100644 --- a/Utils/Converter/Measurement.php +++ b/Utils/Converter/Measurement.php @@ -19,7 +19,7 @@ namespace phpOMS\Utils\Converter; * Measurement converter. * * @category Framework - * @package Converter + * @package phpOMS\Utils\Converter * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Converter/Numeric.php b/Utils/Converter/Numeric.php index 6c478edd4..3fe7d1492 100644 --- a/Utils/Converter/Numeric.php +++ b/Utils/Converter/Numeric.php @@ -19,7 +19,7 @@ namespace phpOMS\Utils\Converter; * Numeric converter. * * @category Framework - * @package Converter + * @package phpOMS\Utils\Converter * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Converter/TemperatureType.php b/Utils/Converter/TemperatureType.php index be89892d3..7bbbdccd5 100644 --- a/Utils/Converter/TemperatureType.php +++ b/Utils/Converter/TemperatureType.php @@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum; * Temperature type enum. * * @category Framework - * @package Converter + * @package phpOMS\Utils\Converter * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Encoding/Ceasar.php b/Utils/Encoding/Ceasar.php new file mode 100644 index 000000000..19705dc02 --- /dev/null +++ b/Utils/Encoding/Ceasar.php @@ -0,0 +1,84 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Utils\Encoding; + +/** + * Gray encoding class + * + * @category Framework + * @package phpOMS\Utils + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Ceasar { + const LIMIT_LOWER = 0; + const LIMIT_UPPER = 127; + + /** + * {@inheritdoc} + */ + public static function encode(string $source, string $key) : string + { + $result = ''; + $length = strlen($source); + $keyLength = strlen($key)-1; + + for($i = 0, $j = 0; $i < $length; $i++, $j++) { + if($j > $keyLength) { + $j = 0; + } + + $ascii = ord($source[$i]) + ord($key[$j]); + + if($ascii > self::LIMIT_UPPER) { + $ascii -= self::LIMIT_UPPER; + } + + $result .= char($ascii); + } + + return $result; + } + + /** + * {@inheritdoc} + */ + public static function decode(string $raw, string $key) : string + { + $result = ''; + $length = strlen($raw); + $keyLength = strlen($key)-1; + + for($i = 0, $j = 0; $i < $length; $i++, $j++) { + if($j > $keyLength) { + $j = 0; + } + + $ascii = ord($raw[$i]) - ord($key[$j]); + + if($ascii < self::LIMIT_LOWER) { + $ascii += self::LIMIT_LOWER; + } + + $result .= char($ascii); + } + + return $result; + } +} \ No newline at end of file diff --git a/Utils/Encoding/EncodingInterface.php b/Utils/Encoding/EncodingInterface.php index ca331d55d..448e3a776 100644 --- a/Utils/Encoding/EncodingInterface.php +++ b/Utils/Encoding/EncodingInterface.php @@ -19,7 +19,7 @@ namespace phpOMS\Utils\Encoding; * Encoding Interface * * @category Framework - * @package phpOMS\Asset + * @package phpOMS\Utils * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Encoding/Gray.php b/Utils/Encoding/Gray.php index 96a90a478..d4a157334 100644 --- a/Utils/Encoding/Gray.php +++ b/Utils/Encoding/Gray.php @@ -19,7 +19,7 @@ namespace phpOMS\Utils\Encoding; * Gray encoding class * * @category Framework - * @package phpOMS\Asset + * @package phpOMS\Utils * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Encoding/Xor.php b/Utils/Encoding/Xor.php new file mode 100644 index 000000000..56dcf8c57 --- /dev/null +++ b/Utils/Encoding/Xor.php @@ -0,0 +1,59 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Utils\Encoding; + +/** + * Gray encoding class + * + * @category Framework + * @package phpOMS\Utils + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Xor { + + /** + * {@inheritdoc} + */ + public static function encode(string $source, string $key) : string + { + $result = ''; + $length = strlen($source); + $keyLength = strlen($key)-1; + + for($i = 0, $j = 0; $i < $length; $i++, $j++) { + if($j > $keyLength) { + $j = 0; + } + + $ascii = ord($source[$i]) ^ ord($key[$j]); + $result .= char($ascii); + } + + return $result; + } + + /** + * {@inheritdoc} + */ + public static function decode(string $raw, string $key) : string + { + return self::encode($raw, $key) + } +} \ No newline at end of file diff --git a/Utils/JsonBuilder.php b/Utils/JsonBuilder.php index 7f6a9cb7f..4ca3aec21 100644 --- a/Utils/JsonBuilder.php +++ b/Utils/JsonBuilder.php @@ -15,8 +15,6 @@ */ namespace phpOMS\Utils; - - /** * Json builder class. * diff --git a/Utils/Parser/Php/ArrayParser.php b/Utils/Parser/Php/ArrayParser.php index bdc81c72d..dd9246c9f 100644 --- a/Utils/Parser/Php/ArrayParser.php +++ b/Utils/Parser/Php/ArrayParser.php @@ -20,8 +20,8 @@ namespace phpOMS\Utils\Parser\Php; * * Parsing/serializing arrays to and from php file * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\Utils\Parser * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Parser/Php/ClassParser.php b/Utils/Parser/Php/ClassParser.php index d438e18ef..523987588 100644 --- a/Utils/Parser/Php/ClassParser.php +++ b/Utils/Parser/Php/ClassParser.php @@ -20,8 +20,8 @@ namespace phpOMS\Utils\Parser\Php; * * Parsing/serializing arrays to and from php file * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\Utils\Parser * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Parser/Php/ClassType.php b/Utils/Parser/Php/ClassType.php index 13a678aeb..d7ab2caaa 100644 --- a/Utils/Parser/Php/ClassType.php +++ b/Utils/Parser/Php/ClassType.php @@ -23,7 +23,7 @@ use phpOMS\Datatypes\Enum; * Database types that are supported by the application * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Utils\Parser * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Parser/Php/FunctionParser.php b/Utils/Parser/Php/FunctionParser.php index 0ef81dda3..e205429a4 100644 --- a/Utils/Parser/Php/FunctionParser.php +++ b/Utils/Parser/Php/FunctionParser.php @@ -20,8 +20,8 @@ namespace phpOMS\Utils\Parser\Php; * * Parsing/serializing variables * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\Utils\Parser * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Parser/Php/MemberParser.php b/Utils/Parser/Php/MemberParser.php index 4a274180c..d8d06f82f 100644 --- a/Utils/Parser/Php/MemberParser.php +++ b/Utils/Parser/Php/MemberParser.php @@ -20,8 +20,8 @@ namespace phpOMS\Utils\Parser\Php; * * Parsing/serializing variables * - * @category System - * @package Framework + * @category Framework + * @package phpOMS\Utils\Parser * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Parser/Php/Visibility.php b/Utils/Parser/Php/Visibility.php index fba0fb457..5a3cedccf 100644 --- a/Utils/Parser/Php/Visibility.php +++ b/Utils/Parser/Php/Visibility.php @@ -23,7 +23,7 @@ use phpOMS\Datatypes\Enum; * Database types that are supported by the application * * @category Framework - * @package phpOMS\DataStorage\Database + * @package phpOMS\Utils\Parser * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/Permutation.php b/Utils/Permutation.php index 97c74cfb9..6fdf5d533 100644 --- a/Utils/Permutation.php +++ b/Utils/Permutation.php @@ -1,11 +1,43 @@ + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ namespace phpOMS\Utils; +/** + * String utils. + * + * @category Framework + * @package phpOMS\Utils + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ class Permutation { /** - * usage: permut(['a', 'b', 'c']); + * Create all permutations. + * + * @param array $toPermute data to permutate + * @param array $result existing permutations + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn */ public static function permut(array $toPermute, array $result = []) : array { @@ -25,4 +57,70 @@ class Permutation return $permutations; } + + /** + * Check if two strings are permutations of each other. + * + * @param string $a String a + * @param string $b String b + * + * @return bool + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function isPermutation(string $a, string $b) : bool + { + return count_chars($a, 1) === count_chars($b, 1); + } + + /** + * Check if a string is a palindrome. + * + * @param string $a String a + * @param string $filter Characters to filter + * + * @return bool + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function isPalindrome(string $a, string $filter = 'a-zA-Z0-9') : bool + { + $a = strtolower(preg_replace('/[^' . $filter . ']/', '', $a)); + + return $a === strrev($a); + } + + /** + * Permutate based on transposition key. + * + * @param string|array $toPermute To permutate + * @param array $key Permutation keys + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function permutate($toPermute, array $key) + { + if(!is_array($toPermute) || !is_string($toPermute)) { + throw new \Exception(); + } + + if(count($key) > strlen($toPermute)) { + throw new \Exception(); + } + + $i = 0; + for($key as $pos) { + $temp = $toPermute[$i] + $toPermute[$i] = $toPermute[$pos]; + $toPermute[$pos] = $temp; + $i++; + } + + return $toPermute; + } } \ No newline at end of file diff --git a/Utils/StringUtils.php b/Utils/StringUtils.php index 304d8f317..47f29087f 100644 --- a/Utils/StringUtils.php +++ b/Utils/StringUtils.php @@ -19,7 +19,7 @@ namespace phpOMS\Utils; * String utils. * * @category Framework - * @package Utils + * @package phpOMS\Utils * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 diff --git a/Views/View.php b/Views/View.php index 9e08b94a3..2d0655dff 100644 --- a/Views/View.php +++ b/Views/View.php @@ -25,8 +25,8 @@ use phpOMS\Validation\Validator; /** * List view. * - * @category Theme - * @package Framework + * @category Framework + * @package phpOMS/Views * @author OMS Development Team * @author Dennis Eichhorn * @license OMS License 1.0 @@ -340,6 +340,14 @@ class View implements \Serializable $this->data[$id] = $data; } + /** + * Arrayify view and it's subviews. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getArray() : array { $viewArray = []; @@ -351,11 +359,27 @@ class View implements \Serializable } } + /** + * Serialize view for rendering. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function serialize() { return $this->render(); } + /** + * Unserialize view. + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function unserialize($raw) {