diff --git a/Account/Group.php b/Account/Group.php index 4cf528185..7fc6949f7 100644 --- a/Account/Group.php +++ b/Account/Group.php @@ -84,15 +84,6 @@ class Group implements ArrayableInterface, \JsonSerializable */ protected $permissions = []; - /** - * Constructor. - * - * @since 1.0.0 - */ - public function __construct() - { - } - /** * Get group id. * diff --git a/Business/Finance/Forecasting/ARIMA.php b/Business/Finance/Forecasting/ARIMA.php index 833d43b77..bc1f074e3 100644 --- a/Business/Finance/Forecasting/ARIMA.php +++ b/Business/Finance/Forecasting/ARIMA.php @@ -4,7 +4,7 @@ * * PHP Version 7.2 * - * @package TBD + * @package phpOMS\Business\Finance\Forecasting * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -15,12 +15,40 @@ namespace phpOMS\Business\Finance\Forecasting; use phpOMS\Math\Statistic\Average; +/** + * Arima forecasting class. + * + * @package phpOMS\Business\Finance\Forecasting + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ class ARIMA { + /** + * Data points + * + * @var array + * @since 1.0.0 + */ private $data = []; + /** + * Intervals of the time series + * + * @var array + * @since 1.0.0 + */ private $order = 0; + /** + * Constructor. + * + * @param array $data Data points + * @param int $order Data intervals (only 12 and 4 are valid). + * + * @since 1.0.0 + */ public function __construct(array $data, int $order = 12) { $this->data = $data; @@ -31,6 +59,13 @@ class ARIMA } } + /** + * Return data decomposition. + * + * @return array + * + * @since 1.0.0 + */ public function getDecomposition() : array { $iteration1 = $this->getIteration($this->data); diff --git a/DataStorage/Database/Connection/PostgresConnection.php b/DataStorage/Database/Connection/PostgresConnection.php index 2f65da577..447829736 100644 --- a/DataStorage/Database/Connection/PostgresConnection.php +++ b/DataStorage/Database/Connection/PostgresConnection.php @@ -14,6 +14,12 @@ declare(strict_types=1); namespace phpOMS\DataStorage\Database\Connection; +use phpOMS\DataStorage\Database\DatabaseStatus; +use phpOMS\DataStorage\Database\DatabaseType; +use phpOMS\DataStorage\Database\Query\Grammar\PostgresGrammar; +use phpOMS\DataStorage\Database\Schema\Grammar\PostgresGrammar as PostgresSchemaGrammar; +use phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException; + /** * Database handler. * @@ -25,7 +31,50 @@ namespace phpOMS\DataStorage\Database\Connection; * @link http://website.orange-management.de * @since 1.0.0 */ -final class PostgresConnection extends \Exception +final class PostgresConnection extends ConnectionAbstract { + /** + * Object constructor. + * + * Creates the database object and overwrites all default values. + * + * @param string[] $dbdata the basic database information for establishing a connection + * + * @since 1.0.0 + */ + public function __construct(array $dbdata) + { + $this->type = DatabaseType::PGSQL; + $this->grammar = new PostgresGrammar(); + $this->schemaGrammar = new PostgresSchemaGrammar(); + $this->connect($dbdata); // todo: remove since this is a side effect that doesn't belong to constructor + } + /** + * {@inheritdoc} + */ + public function connect(array $dbdata = null) : void + { + $this->dbdata = isset($dbdata) ? $dbdata : $this->dbdata; + + if (!isset($this->dbdata['db'], $this->dbdata['host'], $this->dbdata['port'], $this->dbdata['database'], $this->dbdata['login'], $this->dbdata['password'])) { + throw new InvalidConnectionConfigException(json_encode($this->dbdata)); + } + + $this->close(); + $this->prefix = $dbdata['prefix'] ?? ''; + + try { + $this->con = new \PDO($this->dbdata['db'] . ':host=' . $this->dbdata['host'] . ':' . $this->dbdata['port'] . ';dbname=' . $this->dbdata['database'] . ';charset=utf8', $this->dbdata['login'], $this->dbdata['password']); + $this->con->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); + $this->con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + + $this->status = DatabaseStatus::OK; + } catch (\PDOException $e) { + $this->status = DatabaseStatus::MISSING_DATABASE; + $this->con = null; + } finally { + $this->dbdata['password'] = '****'; + } + } } diff --git a/Dispatcher/Dispatcher.php b/Dispatcher/Dispatcher.php index 5113b66fa..8cdfaf961 100644 --- a/Dispatcher/Dispatcher.php +++ b/Dispatcher/Dispatcher.php @@ -93,8 +93,8 @@ final class Dispatcher /** * Dispatch string. * - * @param string $controller Controller string - * @param array|null $data Data + * @param string $controller Controller string + * @param array|null $data Data * * @return array * diff --git a/Message/Console/Request.php b/Message/Console/Request.php index 50f699adf..28f1de400 100644 --- a/Message/Console/Request.php +++ b/Message/Console/Request.php @@ -12,7 +12,7 @@ */ declare(strict_types=1); -namespace phpOMS\Message\Http; +namespace phpOMS\Message\Console; use phpOMS\Localization\Localization; use phpOMS\Message\RequestAbstract; @@ -29,7 +29,7 @@ use phpOMS\Router\RouteVerb; * * @SuppressWarnings(PHPMD.Superglobals) */ -class Request extends RequestAbstract +final class Request extends RequestAbstract { /** * OS type. @@ -101,4 +101,53 @@ class Request extends RequestAbstract return $this->os; } + + /** + * {@inheritdoc} + */ + public function getOrigin() : string + { + // todo: maybe return execution path? + return '127.0.0.1'; + } + + /** + * {@inheritdoc} + */ + public function getMethod() : string + { + if ($this->method === null) { + $this->method = RequestMethod::GET; + } + + return $this->method; + } + + /** + * {@inheritdoc} + */ + public function getBody() : string + { + // todo: implement + return ''; + } + + /** + * {@inheritdoc} + */ + public function getRouteVerb() : int + { + switch ($this->getMethod()) { + case RequestMethod::GET: + return RouteVerb::GET; + case RequestMethod::PUT: + return RouteVerb::PUT; + case RequestMethod::POST: + return RouteVerb::SET; + case RequestMethod::DELETE: + return RouteVerb::DELETE; + default: + throw new \Exception(); + } + } } diff --git a/Message/Http/Request.php b/Message/Http/Request.php index 7de42d828..f05d1a2f9 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -391,14 +391,6 @@ final class Request extends RequestAbstract return file_get_contents('php://input'); } - /** - * {@inheritdoc} - */ - public function getRequestTarget() : string - { - return '/'; - } - /** * Get files passed in request. * @@ -412,13 +404,7 @@ final class Request extends RequestAbstract } /** - * Get route verb for this request. - * - * @return int - * - * @throws \Exception - * - * @since 1.0.0 + * {@inheritdoc} */ public function getRouteVerb() : int { @@ -437,11 +423,7 @@ final class Request extends RequestAbstract } /** - * Get request type. - * - * @return string - * - * @since 1.0.0 + * {@inheritdoc} */ public function getMethod() : string { diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index df38aadd3..fa23aa1db 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -248,15 +248,6 @@ abstract class RequestAbstract implements MessageInterface return $this->uri->__toString(); } - /** - * Get request target. - * - * @return string - * - * @since 1.0.0 - */ - abstract public function getRequestTarget() : string; - /** * Get route verb. * diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 0f22f22f9..b5d571b4a 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -253,8 +253,6 @@ class Repository } $this->run('init'); - - return; } /**