PHP CS fixes

This commit is contained in:
Dennis Eichhorn 2018-05-14 21:17:44 +02:00
parent 59d3f98110
commit f2591bff06
8 changed files with 141 additions and 46 deletions

View File

@ -84,15 +84,6 @@ class Group implements ArrayableInterface, \JsonSerializable
*/
protected $permissions = [];
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
}
/**
* Get group id.
*

View File

@ -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);

View File

@ -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'] = '****';
}
}
}

View File

@ -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
*

View File

@ -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();
}
}
}

View File

@ -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
{

View File

@ -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.
*

View File

@ -253,8 +253,6 @@ class Repository
}
$this->run('init');
return;
}
/**