remove some getter/setter

This commit is contained in:
Dennis Eichhorn 2020-11-24 17:31:21 +01:00
parent 1d5b727465
commit 86d62a1bb5
78 changed files with 401 additions and 1472 deletions

View File

@ -46,7 +46,7 @@ class Account implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $name1 = ''; public string $name1 = '';
/** /**
* Names. * Names.
@ -54,7 +54,7 @@ class Account implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $name2 = ''; public string $name2 = '';
/** /**
* Names. * Names.
@ -62,7 +62,7 @@ class Account implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $name3 = ''; public string $name3 = '';
/** /**
* Email. * Email.
@ -88,7 +88,7 @@ class Account implements \JsonSerializable, ArrayableInterface
* @var null|string * @var null|string
* @since 1.0.0 * @since 1.0.0
*/ */
protected ?string $login = null; public ?string $login = null;
/** /**
* Last activity. * Last activity.
@ -104,7 +104,7 @@ class Account implements \JsonSerializable, ArrayableInterface
* @var \DateTimeImmutable * @var \DateTimeImmutable
* @since 1.0.0 * @since 1.0.0
*/ */
protected \DateTimeImmutable $createdAt; public \DateTimeImmutable $createdAt;
/** /**
* Groups. * Groups.
@ -144,7 +144,7 @@ class Account implements \JsonSerializable, ArrayableInterface
* @var Localization * @var Localization
* @since 1.0.0 * @since 1.0.0
*/ */
protected $localization; public Localization $l11n;
use PermissionHandlingTrait; use PermissionHandlingTrait;
@ -159,10 +159,10 @@ class Account implements \JsonSerializable, ArrayableInterface
*/ */
public function __construct(int $id = 0) public function __construct(int $id = 0)
{ {
$this->createdAt = new \DateTimeImmutable('now'); $this->createdAt = new \DateTimeImmutable('now');
$this->lastActive = new \DateTime('now'); $this->lastActive = new \DateTime('now');
$this->id = $id; $this->id = $id;
$this->localization = new Localization(); $this->l11n = new Localization();
} }
/** /**
@ -177,20 +177,6 @@ class Account implements \JsonSerializable, ArrayableInterface
return $this->id; return $this->id;
} }
/**
* Get localization.
*
* Every account can have a different localization which can be accessed here.
*
* @return Localization
*
* @since 1.0.0
*/
public function getL11n()
{
return $this->localization;
}
/** /**
* Get groups. * Get groups.
* *
@ -220,110 +206,6 @@ class Account implements \JsonSerializable, ArrayableInterface
$this->groups[] = $group; $this->groups[] = $group;
} }
/**
* Set localization.
*
* @param Localization $l11n Localization
*
* @return void
*
* @since 1.0.0
*/
public function setL11n(Localization $l11n) : void
{
$this->localization = $l11n;
}
/**
* Get name.
*
* @return string Returns the login name or null
*
* @since 1.0.0
*/
public function getName() : ?string
{
return $this->login;
}
/**
* Get name1.
*
* @return string Returns the name1
*
* @since 1.0.0
*/
public function getName1() : string
{
return $this->name1;
}
/**
* Set name1.
*
* @param string $name Name
*
* @return void
*
* @since 1.0.0
*/
public function setName1(string $name) : void
{
$this->name1 = $name;
}
/**
* Get name2.
*
* @return string Returns name 2
*
* @since 1.0.0
*/
public function getName2() : string
{
return $this->name2;
}
/**
* Set name2.
*
* @param string $name Name
*
* @return void
*
* @since 1.0.0
*/
public function setName2(string $name) : void
{
$this->name2 = $name;
}
/**
* Get name3.
*
* @return string Returns name 3
*
* @since 1.0.0
*/
public function getName3() : string
{
return $this->name3;
}
/**
* Set name3.
*
* @param string $name Name
*
* @return void
*
* @since 1.0.0
*/
public function setName3(string $name) : void
{
$this->name3 = $name;
}
/** /**
* Get email. * Get email.
* *
@ -429,19 +311,7 @@ class Account implements \JsonSerializable, ArrayableInterface
*/ */
public function getLastActive() : \DateTimeInterface public function getLastActive() : \DateTimeInterface
{ {
return $this->lastActive ?? $this->getCreatedAt(); return $this->lastActive ?? $this->createdAt;
}
/**
* Get created at.
*
* @return \DateTimeImmutable
*
* @since 1.0.0
*/
public function getCreatedAt() : \DateTimeImmutable
{
return $this->createdAt;
} }
/** /**
@ -466,20 +336,6 @@ class Account implements \JsonSerializable, ArrayableInterface
$this->password = $temp; $this->password = $temp;
} }
/**
* Set name.
*
* @param string $name Name
*
* @return void
*
* @since 1.0.0
*/
public function setName(string $name) : void
{
$this->login = $name;
}
/** /**
* Update last activity. * Update last activity.
* *

View File

@ -41,7 +41,7 @@ class Group implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $name = ''; public string $name = '';
/** /**
* Group name. * Group name.
@ -49,7 +49,7 @@ class Group implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $description = ''; public string $description = '';
/** /**
* Group members. * Group members.
@ -89,58 +89,6 @@ class Group implements \JsonSerializable, ArrayableInterface
return $this->id; return $this->id;
} }
/**
* Get group name.
*
* @return string Returns the name of the group
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/**
* Set group name.
*
* @param string $name Group name
*
* @return void
*
* @since 1.0.0
*/
public function setName(string $name) : void
{
$this->name = $name;
}
/**
* Get group description.
*
* @return string Returns the description of the group
*
* @since 1.0.0
*/
public function getDescription() : string
{
return $this->description;
}
/**
* Set group description.
*
* @param string $description Group description
*
* @return void
*
* @since 1.0.0
*/
public function setDescription(string $description) : void
{
$this->description = $description;
}
/** /**
* Get group status. * Get group status.
* *

View File

@ -134,11 +134,11 @@ final class Kmeans
} }
foreach ($points as $point) { foreach ($points as $point) {
$clusterPoint = $clusterCenters[$point->getGroup()]; $clusterPoint = $clusterCenters[$point->group];
// this should ensure that clusterPoint and therfore the center group is never 0. But this is not true. // this should ensure that clusterPoint and therfore the center group is never 0. But this is not true.
$clusterPoint->setGroup( $clusterPoint->group = (
$clusterPoint->getGroup() + 1 $clusterPoint->group + 1
); );
for ($i = 0; $i < $coordinates; ++$i) { for ($i = 0; $i < $coordinates; ++$i) {
@ -153,9 +153,9 @@ final class Kmeans
* Invalid center coodinate value * Invalid center coodinate value
* In some cases the center point of a cluster belongs to the group 0 in this case the coordinate value is not working correctly. * In some cases the center point of a cluster belongs to the group 0 in this case the coordinate value is not working correctly.
* As a quick fix the value is set to `1` in such a case but probably has multiple side effects. * As a quick fix the value is set to `1` in such a case but probably has multiple side effects.
* Maybe it makes sense to just use `$center->getGroup() + 1` or set the value to `0`. * Maybe it makes sense to just use `$center->group + 1` or set the value to `0`.
*/ */
$center->setCoordinate($i, $center->getCoordinate($i) / ($center->getGroup() === 0 ? 1 : $center->getGroup())); $center->setCoordinate($i, $center->getCoordinate($i) / ($center->group === 0 ? 1 : $center->group));
} }
} }
@ -163,9 +163,9 @@ final class Kmeans
foreach ($points as $point) { foreach ($points as $point) {
$min = $this->nearestClusterCenter($point, $clusterCenters)[0]; $min = $this->nearestClusterCenter($point, $clusterCenters)[0];
if ($min !== $point->getGroup()) { if ($min !== $point->group) {
++$changed; ++$changed;
$point->setGroup($min); $point->group = ($min);
} }
} }
@ -175,8 +175,8 @@ final class Kmeans
} }
foreach ($clusterCenters as $key => $center) { foreach ($clusterCenters as $key => $center) {
$center->setGroup($key); $center->group = ($key);
$center->setName((string) $key); $center->name = (string) $key;
} }
$this->clusterCenters = $clusterCenters; $this->clusterCenters = $clusterCenters;
@ -194,7 +194,7 @@ final class Kmeans
*/ */
private function nearestClusterCenter(PointInterface $point, array $clusterCenters) : array private function nearestClusterCenter(PointInterface $point, array $clusterCenters) : array
{ {
$index = $point->getGroup(); $index = $point->group;
$dist = \PHP_FLOAT_MAX; $dist = \PHP_FLOAT_MAX;
foreach ($clusterCenters as $key => $cPoint) { foreach ($clusterCenters as $key => $cPoint) {
@ -244,7 +244,7 @@ final class Kmeans
} }
foreach ($points as $point) { foreach ($points as $point) {
$point->setGroup($this->nearestClusterCenter($point, $clusters)[0]); $point->group = ($this->nearestClusterCenter($point, $clusters)[0]);
} }
return $clusters; return $clusters;

View File

@ -38,7 +38,7 @@ class Point implements PointInterface
* @var int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
private int $group = 0; public int $group = 0;
/** /**
* Name of the point * Name of the point
@ -46,7 +46,7 @@ class Point implements PointInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Constructor. * Constructor.
@ -85,36 +85,4 @@ class Point implements PointInterface
{ {
$this->coordinates[$index] = $value; $this->coordinates[$index] = $value;
} }
/**
* {@inheritdoc}
*/
public function getGroup() : int
{
return $this->group;
}
/**
* {@inheritdoc}
*/
public function setGroup(int $group) : void
{
$this->group = $group;
}
/**
* {@inheritdoc}
*/
public function setName(string $name) : void
{
$this->name = $name;
}
/**
* {@inheritdoc}
*/
public function getName() : string
{
return $this->name;
}
} }

View File

@ -56,44 +56,4 @@ interface PointInterface
* @since 1.0.0 * @since 1.0.0
*/ */
public function setCoordinate(int $index, $value) : void; public function setCoordinate(int $index, $value) : void;
/**
* Get group this point belongs to
*
* @return int
*
* @since 1.0.0
*/
public function getGroup() : int;
/**
* Set the group this point belongs to
*
* @param int $group Group or cluster this point belongs to
*
* @return void
*
* @since 1.0.0
*/
public function setGroup(int $group) : void;
/**
* Set the point name
*
* @param string $name Name of the point
*
* @return void
*
* @since 1.0.0
*/
public function setName(string $name) : void;
/**
* Get the name of the point
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string;
} }

View File

@ -54,7 +54,7 @@ class Job implements JobInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Cosntructor. * Cosntructor.
@ -96,12 +96,4 @@ class Job implements JobInterface
{ {
return $this->end; return $this->end;
} }
/**
* {@inheritdoc}
*/
public function getName() : string
{
return $this->name;
}
} }

View File

@ -51,13 +51,4 @@ interface JobInterface
* @since 1.0.0 * @since 1.0.0
*/ */
public function getEnd() : ?\DateTime; public function getEnd() : ?\DateTime;
/**
* Get the name of the job
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string;
} }

View File

@ -46,7 +46,7 @@ class Item implements ItemInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Cosntructor. * Cosntructor.

View File

@ -84,7 +84,7 @@ final class AStar implements PathFinderInterface
$neighbor->setG($ng); $neighbor->setG($ng);
$neighbor->setH($neighbor->getG() ?? $neighbor->getWeight() * Heuristic::metric($neighbor->getCoordinates(), $endNode->getCoordinates(), $heuristic)); $neighbor->setH($neighbor->getG() ?? $neighbor->getWeight() * Heuristic::metric($neighbor->getCoordinates(), $endNode->getCoordinates(), $heuristic));
$neighbor->setF($neighbor->getG() + $neighbor->getH()); $neighbor->setF($neighbor->getG() + $neighbor->getH());
$neighbor->setParent($node); $neighbor->parent = $node;
if (!$neighbor->isOpened()) { if (!$neighbor->isOpened()) {
$openList->push($neighbor); $openList->push($neighbor);
@ -100,7 +100,7 @@ final class AStar implements PathFinderInterface
while ($node !== null) { while ($node !== null) {
$path->addNode($node); $path->addNode($node);
$node = $node->getParent(); $node = $node->parent;
} }
return $path; return $path;

View File

@ -130,7 +130,7 @@ class Grid
*/ */
public function isWalkable(int $x, int $y) : bool public function isWalkable(int $x, int $y) : bool
{ {
return isset($this->nodes[$y]) && isset($this->nodes[$y][$x]) && $this->nodes[$y][$x]->isWalkable(); return isset($this->nodes[$y]) && isset($this->nodes[$y][$x]) && $this->nodes[$y][$x]->isWalkable;
} }
/** /**

View File

@ -75,7 +75,7 @@ final class JumpPointSearch implements PathFinderInterface
while ($node !== null) { while ($node !== null) {
$path->addNode($node); $path->addNode($node);
$node = $node->getParent(); $node = $node->parent;
} }
return $path; return $path;
@ -121,7 +121,7 @@ final class JumpPointSearch implements PathFinderInterface
$jumpPoint->setG($ng); $jumpPoint->setG($ng);
$jumpPoint->setH($jumpPoint->getH() ?? Heuristic::metric($jumpPoint->getCoordinates(), $endNode->getCoordinates(), $heuristic)); $jumpPoint->setH($jumpPoint->getH() ?? Heuristic::metric($jumpPoint->getCoordinates(), $endNode->getCoordinates(), $heuristic));
$jumpPoint->setF($jumpPoint->getG() + $jumpPoint->getH()); $jumpPoint->setF($jumpPoint->getG() + $jumpPoint->getH());
$jumpPoint->setParent($node); $jumpPoint->parent = $node;
if (!$jumpPoint->isOpened()) { if (!$jumpPoint->isOpened()) {
$openList->push($jumpPoint); $openList->push($jumpPoint);
@ -171,15 +171,15 @@ final class JumpPointSearch implements PathFinderInterface
*/ */
private static function findNeighborsStraight(JumpPointNode $node, Grid $grid) : array private static function findNeighborsStraight(JumpPointNode $node, Grid $grid) : array
{ {
if ($node->getParent() === null) { if ($node->parent === null) {
return $grid->getNeighbors($node, MovementType::STRAIGHT); return $grid->getNeighbors($node, MovementType::STRAIGHT);
} }
$x = $node->getX(); $x = $node->getX();
$y = $node->getY(); $y = $node->getY();
$px = $node->getParent()->getX(); $px = $node->parent->getX();
$py = $node->getParent()->getY(); $py = $node->parent->getY();
/** @var int $dx */ /** @var int $dx */
$dx = ($x - $px) / \max(\abs($x - $px), 1); $dx = ($x - $px) / \max(\abs($x - $px), 1);
@ -229,15 +229,15 @@ final class JumpPointSearch implements PathFinderInterface
*/ */
private static function findNeighborsDiagonal(JumpPointNode $node, Grid $grid) : array private static function findNeighborsDiagonal(JumpPointNode $node, Grid $grid) : array
{ {
if ($node->getParent() === null) { if ($node->parent === null) {
return $grid->getNeighbors($node, MovementType::DIAGONAL); return $grid->getNeighbors($node, MovementType::DIAGONAL);
} }
$x = $node->getX(); $x = $node->getX();
$y = $node->getY(); $y = $node->getY();
$px = $node->getParent()->getX(); $px = $node->parent->getX();
$py = $node->getParent()->getY(); $py = $node->parent->getY();
/** @var int $dx */ /** @var int $dx */
$dx = ($x - $px) / \max(\abs($x - $px), 1); $dx = ($x - $px) / \max(\abs($x - $px), 1);
@ -307,15 +307,15 @@ final class JumpPointSearch implements PathFinderInterface
*/ */
private static function findNeighborsDiagonalOneObstacle(JumpPointNode $node, Grid $grid) : array private static function findNeighborsDiagonalOneObstacle(JumpPointNode $node, Grid $grid) : array
{ {
if ($node->getParent() === null) { if ($node->parent === null) {
return $grid->getNeighbors($node, MovementType::DIAGONAL_ONE_OBSTACLE); return $grid->getNeighbors($node, MovementType::DIAGONAL_ONE_OBSTACLE);
} }
$x = $node->getX(); $x = $node->getX();
$y = $node->getY(); $y = $node->getY();
$px = $node->getParent()->getX(); $px = $node->parent->getX();
$py = $node->getParent()->getY(); $py = $node->parent->getY();
/** @var int $dx */ /** @var int $dx */
$dx = ($x - $px) / \max(\abs($x - $px), 1); $dx = ($x - $px) / \max(\abs($x - $px), 1);
@ -381,15 +381,15 @@ final class JumpPointSearch implements PathFinderInterface
*/ */
private static function findNeighborsDiagonalNoObstacle(JumpPointNode $node, Grid $grid) : array private static function findNeighborsDiagonalNoObstacle(JumpPointNode $node, Grid $grid) : array
{ {
if ($node->getParent() === null) { if ($node->parent === null) {
return $grid->getNeighbors($node, MovementType::DIAGONAL_NO_OBSTACLE); return $grid->getNeighbors($node, MovementType::DIAGONAL_NO_OBSTACLE);
} }
$x = $node->getX(); $x = $node->getX();
$y = $node->getY(); $y = $node->getY();
$px = $node->getParent()->getX(); $px = $node->parent->getX();
$py = $node->getParent()->getY(); $py = $node->parent->getY();
/** @var int $dx */ /** @var int $dx */
$dx = ($x - $px) / \max(\abs($x - $px), 1); $dx = ($x - $px) / \max(\abs($x - $px), 1);
@ -501,7 +501,7 @@ final class JumpPointSearch implements PathFinderInterface
*/ */
private static function jumpStraight(?JumpPointNode $node, ?JumpPointNode $pNode, JumpPointNode $endNode, Grid $grid) : ?JumpPointNode private static function jumpStraight(?JumpPointNode $node, ?JumpPointNode $pNode, JumpPointNode $endNode, Grid $grid) : ?JumpPointNode
{ {
if ($node === null || $pNode === null || !$node->isWalkable()) { if ($node === null || $pNode === null || !$node->isWalkable) {
return null; return null;
} }
@ -557,7 +557,7 @@ final class JumpPointSearch implements PathFinderInterface
*/ */
private static function jumpDiagonal(?JumpPointNode $node, ?JumpPointNode $pNode, JumpPointNode $endNode, Grid $grid) : ?JumpPointNode private static function jumpDiagonal(?JumpPointNode $node, ?JumpPointNode $pNode, JumpPointNode $endNode, Grid $grid) : ?JumpPointNode
{ {
if ($node === null || $pNode === null || !$node->isWalkable()) { if ($node === null || $pNode === null || !$node->isWalkable) {
return null; return null;
} }
@ -617,7 +617,7 @@ final class JumpPointSearch implements PathFinderInterface
*/ */
private static function jumpDiagonalOneObstacle(?JumpPointNode $node, ?JumpPointNode $pNode, JumpPointNode $endNode, Grid $grid) : ?JumpPointNode private static function jumpDiagonalOneObstacle(?JumpPointNode $node, ?JumpPointNode $pNode, JumpPointNode $endNode, Grid $grid) : ?JumpPointNode
{ {
if ($node === null || $pNode === null || !$node->isWalkable()) { if ($node === null || $pNode === null || !$node->isWalkable) {
return null; return null;
} }
@ -681,7 +681,7 @@ final class JumpPointSearch implements PathFinderInterface
*/ */
private static function jumpDiagonalNoObstacle(?JumpPointNode $node, ?JumpPointNode $pNode, JumpPointNode $endNode, Grid $grid) : ?JumpPointNode private static function jumpDiagonalNoObstacle(?JumpPointNode $node, ?JumpPointNode $pNode, JumpPointNode $endNode, Grid $grid) : ?JumpPointNode
{ {
if ($node === null || $pNode === null || !$node->isWalkable()) { if ($node === null || $pNode === null || !$node->isWalkable) {
return null; return null;
} }

View File

@ -54,7 +54,7 @@ class Node
* @var bool * @var bool
* @since 1.0.0 * @since 1.0.0
*/ */
private bool $isWalkable = true; public bool $isWalkable = true;
/** /**
* Parent node. * Parent node.
@ -62,7 +62,7 @@ class Node
* @var null|Node * @var null|Node
* @since 1.0.0 * @since 1.0.0
*/ */
private ?Node $parent = null; public ?Node $parent = null;
/** /**
* Constructor. * Constructor.
@ -82,18 +82,6 @@ class Node
$this->isWalkable = $isWalkable; $this->isWalkable = $isWalkable;
} }
/**
* Can this node be walked on?
*
* @return bool
*
* @since 1.0.0
*/
public function isWalkable() : bool
{
return $this->isWalkable;
}
/** /**
* Get the cost to walk on this node * Get the cost to walk on this node
* *
@ -130,32 +118,6 @@ class Node
return $this->y; return $this->y;
} }
/**
* Set parent node
*
* @param null|Node $node Parent node
*
* @return void
*
* @since 1.0.0
*/
public function setParent(?self $node) : void
{
$this->parent = $node;
}
/**
* Get parent node
*
* @return null|Node
*
* @since 1.0.0
*/
public function getParent() : ?self
{
return $this->parent;
}
/** /**
* Is node equal to another node? * Is node equal to another node?
* *

View File

@ -251,7 +251,7 @@ abstract class ProviderAbstract
protected function parseResponse(HttpResponse $response) : array protected function parseResponse(HttpResponse $response) : array
{ {
$content = $response->getBody(); $content = $response->getBody();
$type = \implode(';', (array) $response->getHeader()->get('Content-Type')); $type = \implode(';', (array) $response->header->get('Content-Type'));
if (\stripos($type, 'urlencoded') !== false) { if (\stripos($type, 'urlencoded') !== false) {
\parse_str($content, $parsed); \parse_str($content, $parsed);

View File

@ -411,7 +411,7 @@ final class FileCache extends ConnectionAbstract
foreach ($dir as $file) { foreach ($dir as $file) {
if ($file instanceof File) { if ($file instanceof File) {
$created = $file->getCreatedAt()->getTimestamp(); $created = $file->createdAt->getTimestamp();
if (($expire >= 0 && $created + $expire < $now) if (($expire >= 0 && $created + $expire < $now)
|| ($expire < 0 && $created + $this->getExpire($file->getContent()) < $now) || ($expire < 0 && $created + $this->getExpire($file->getContent()) < $now)
) { ) {

View File

@ -768,13 +768,13 @@ class DataMapperAbstract implements DataMapperInterface
$relReflectionClass = new \ReflectionClass($values); $relReflectionClass = new \ReflectionClass($values);
$relProperty = $relReflectionClass->getProperty($mapper::$columns[static::$hasMany[$propertyName]['self']]['internal']); $relProperty = $relReflectionClass->getProperty($mapper::$columns[static::$hasMany[$propertyName]['self']]['internal']);
if (!$isPublic) { if (!($isPublicRel = $relProperty->isPublic())) {
$relProperty->setAccessible(true); $relProperty->setAccessible(true);
} }
$relProperty->setValue($values, $objId); $relProperty->setValue($values, $objId);
if (!$isPublic) { if (!$isPublicRel) {
$relProperty->setAccessible(false); $relProperty->setAccessible(false);
} }

View File

@ -30,7 +30,7 @@ class Parameter
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Constructor. * Constructor.

View File

@ -162,23 +162,31 @@ final class EventManager implements \Countable
$groups = []; $groups = [];
foreach ($this->groups as $groupName => $value) { foreach ($this->groups as $groupName => $value) {
$groupNameIsRegex = \stripos($groupName, '/') === 0;
if ($groupIsRegex) { if ($groupIsRegex) {
if (\preg_match($group, $groupName) === 1) { if (\preg_match($group, $groupName) === 1) {
$groups[$groupName] = []; $groups[$groupName] = [];
} }
} elseif (\preg_match($groupName, $group) === 1) { } elseif ($groupNameIsRegex && \preg_match($groupName, $group) === 1) {
$groups[$groupName] = [];
} elseif ($groupName === $group) {
$groups[$groupName] = []; $groups[$groupName] = [];
} }
} }
foreach ($groups as $groupName => $groupValues) { foreach ($groups as $groupName => $groupValues) {
foreach ($this->groups[$groupName] as $idName => $value) { foreach ($this->groups[$groupName] as $idName => $value) {
$idNameIsRegex = \stripos($idName, '/') === 0;
if ($idIsRegex) { if ($idIsRegex) {
if (\preg_match($id, $idName) === 1) { if (\preg_match($id, $idName) === 1) {
$groups[$groupName][] = $idName; $groups[$groupName][] = $idName;
} }
} elseif ($idName !== '' && \preg_match($idName, $id) === 1) { } elseif ($idNameIsRegex && \preg_match($idName, $id) === 1) {
$groups[$groupName][] = $id; $groups[$groupName][] = $id;
} elseif ($idName === $id) {
$groups[$groupName] = [];
} }
} }
@ -218,25 +226,25 @@ final class EventManager implements \Countable
$this->groups[$group][$id] = true; $this->groups[$group][$id] = true;
} }
if (!$this->hasOutstanding($group)) { if ($this->hasOutstanding($group)) {
foreach ($this->callbacks[$group]['callbacks'] as $func) { return false;
if (\is_array($data)) {
$this->dispatcher->dispatch($func, ...$data);
} else {
$this->dispatcher->dispatch($func, $data);
}
}
if ($this->callbacks[$group]['remove']) {
$this->detach($group);
} elseif ($this->callbacks[$group]['reset']) {
$this->reset($group);
}
return true;
} }
return false; foreach ($this->callbacks[$group]['callbacks'] as $func) {
if (\is_array($data)) {
$this->dispatcher->dispatch($func, ...$data);
} else {
$this->dispatcher->dispatch($func, $data);
}
}
if ($this->callbacks[$group]['remove']) {
$this->detach($group);
} elseif ($this->callbacks[$group]['reset']) {
$this->reset($group);
}
return true;
} }
/** /**
@ -354,6 +362,10 @@ final class EventManager implements \Countable
$this->groups[$group] = []; $this->groups[$group] = [];
} }
if (isset($this->groups[$group][''])) {
unset($this->groups[$group]['']);
}
$this->groups[$group][$id] = false; $this->groups[$group][$id] = false;
} }

View File

@ -50,7 +50,7 @@ class Localization implements \JsonSerializable
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $lang = ISO639x1Enum::_EN; protected string $language = ISO639x1Enum::_EN;
/** /**
* Currency. * Currency.
@ -381,7 +381,7 @@ class Localization implements \JsonSerializable
*/ */
public function getLanguage() : string public function getLanguage() : string
{ {
return $this->lang; return $this->language;
} }
/** /**
@ -403,7 +403,7 @@ class Localization implements \JsonSerializable
throw new InvalidEnumValue($language); throw new InvalidEnumValue($language);
} }
$this->lang = $language; $this->language = $language;
} }
/** /**
@ -769,7 +769,7 @@ class Localization implements \JsonSerializable
'id' => $this->id, 'id' => $this->id,
'country' => $this->country, 'country' => $this->country,
'timezone' => $this->timezone, 'timezone' => $this->timezone,
'language' => $this->lang, 'language' => $this->language,
'currency' => $this->currency, 'currency' => $this->currency,
'currencyformat' => $this->currencyFormat, 'currencyformat' => $this->currencyFormat,
'decimal' => $this->decimal, 'decimal' => $this->decimal,

View File

@ -37,7 +37,7 @@ final class ConsoleRequest extends RequestAbstract
* @var UriInterface * @var UriInterface
* @since 1.0.0 * @since 1.0.0
*/ */
protected UriInterface $uri; public UriInterface $uri;
/** /**
* Request method. * Request method.
@ -66,7 +66,7 @@ final class ConsoleRequest extends RequestAbstract
public function __construct(UriInterface $uri = null, Localization $l11n = null) public function __construct(UriInterface $uri = null, Localization $l11n = null)
{ {
$this->header = new ConsoleHeader(); $this->header = new ConsoleHeader();
$this->header->setL11n($l11n ?? new Localization()); $this->header->l11n = $l11n ?? new Localization();
$this->uri = $uri ?? new Argument(); $this->uri = $uri ?? new Argument();
$this->init(); $this->init();
@ -83,7 +83,7 @@ final class ConsoleRequest extends RequestAbstract
*/ */
private function init() : void private function init() : void
{ {
$this->header->getL11n()->setLanguage('en'); $this->header->l11n->setLanguage('en');
} }
/** /**

View File

@ -50,7 +50,7 @@ final class ConsoleResponse extends ResponseAbstract implements RenderableInterf
public function __construct(Localization $l11n = null) public function __construct(Localization $l11n = null)
{ {
$this->header = new ConsoleHeader(); $this->header = new ConsoleHeader();
$this->header->setL11n($l11n ?? new Localization()); $this->header->l11n = $l11n ?? new Localization();
} }
/** /**

View File

@ -40,7 +40,7 @@ abstract class HeaderAbstract
* @var Localization * @var Localization
* @since 1.0.0 * @since 1.0.0
*/ */
protected Localization $l11n; public Localization $l11n;
/** /**
* Account. * Account.
@ -48,7 +48,7 @@ abstract class HeaderAbstract
* @var int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
protected int $account = 0; public int $account = 0;
/** /**
* Response status. * Response status.
@ -56,7 +56,7 @@ abstract class HeaderAbstract
* @var int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
protected int $status = 0; public int $status = 0;
/** /**
* Constructor. * Constructor.
@ -92,72 +92,6 @@ abstract class HeaderAbstract
return $this->isLocked; return $this->isLocked;
} }
/**
* Get Localization
*
* @return Localization
*
* @since 1.0.0
*/
public function getL11n() : Localization
{
return $this->l11n;
}
/**
* Set localization
*
* @param Localization $l11n Localization
*
* @return void
*
* @since 1.0.0
*/
public function setL11n(Localization $l11n) : void
{
$this->l11n = $l11n;
}
/**
* Get account id
*
* @return int
*
* @since 1.0.0
*/
public function getAccount() : int
{
return $this->account;
}
/**
* Set account id
*
* @param int $account Account id
*
* @return void
*
* @since 1.0.0
*/
public function setAccount(int $account) : void
{
$this->account = $account;
}
/**
* Set status code
*
* @param int $status Status code
*
* @return void
*
* @since 1.0.0
*/
public function setStatusCode(int $status) : void
{
$this->status = $status;
}
/** /**
* Generate header based on status code. * Generate header based on status code.
* *
@ -169,18 +103,6 @@ abstract class HeaderAbstract
*/ */
abstract public function generate(int $statusCode) : void; abstract public function generate(int $statusCode) : void;
/**
* Get status code
*
* @return int
*
* @since 1.0.0
*/
public function getStatusCode() : int
{
return $this->status;
}
/** /**
* Get protocol version. * Get protocol version.
* *

View File

@ -45,6 +45,14 @@ final class HttpHeader extends HeaderAbstract
*/ */
private static $serverHeaders = []; private static $serverHeaders = [];
/**
* Response status.
*
* @var int
* @since 1.0.0
*/
public int $status = RequestStatusCode::R_200;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -121,22 +129,6 @@ final class HttpHeader extends HeaderAbstract
return $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1'; return $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1';
} }
/**
* Get status code.
*
* @return int
*
* @since 1.0.0
*/
public function getStatusCode() : int
{
if ($this->status === 0) {
$this->status = RequestStatusCode::R_200;
}
return parent::getStatusCode();
}
/** /**
* Get all headers for apache and nginx * Get all headers for apache and nginx
* *

View File

@ -75,7 +75,7 @@ final class HttpRequest extends RequestAbstract
public function __construct(UriInterface $uri = null, Localization $l11n = null) public function __construct(UriInterface $uri = null, Localization $l11n = null)
{ {
$this->header = new HttpHeader(); $this->header = new HttpHeader();
$this->header->setL11n($l11n ?? new Localization()); $this->header->l11n = $l11n ?? new Localization();
if ($uri !== null) { if ($uri !== null) {
$this->uri = $uri; $this->uri = $uri;
@ -116,7 +116,7 @@ final class HttpRequest extends RequestAbstract
$this->uri = HttpUri::fromCurrent(); $this->uri = HttpUri::fromCurrent();
$this->data = ($_GET ?? []) + ($_POST ?? []); $this->data = ($_GET ?? []) + ($_POST ?? []);
$this->files = $_FILES ?? []; $this->files = $_FILES ?? [];
$this->header->getL11n()->setLanguage($this->getRequestLanguage()); $this->header->l11n->setLanguage($this->getRequestLanguage());
$this->initNonGetData(); $this->initNonGetData();
} }

View File

@ -42,7 +42,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface
public function __construct(Localization $l11n = null) public function __construct(Localization $l11n = null)
{ {
$this->header = new HttpHeader(); $this->header = new HttpHeader();
$this->header->setL11n($l11n ?? new Localization()); $this->header->l11n = $l11n ?? new Localization();
} }
/** /**

View File

@ -48,7 +48,7 @@ final class Rest
\curl_setopt($curl, \CURLOPT_NOBODY, true); \curl_setopt($curl, \CURLOPT_NOBODY, true);
// handle header // handle header
$requestHeaders = $request->getHeader()->get(); $requestHeaders = $request->header->get();
$headers = []; $headers = [];
foreach ($requestHeaders as $key => $header) { foreach ($requestHeaders as $key => $header) {
@ -108,9 +108,9 @@ final class Rest
} }
// handle user auth // handle user auth
if ($request->getUri()->getUser() !== '') { if ($request->uri->user !== '') {
\curl_setopt($curl, \CURLOPT_HTTPAUTH, \CURLAUTH_BASIC); \curl_setopt($curl, \CURLOPT_HTTPAUTH, \CURLAUTH_BASIC);
\curl_setopt($curl, \CURLOPT_USERPWD, $request->getUri()->getUserInfo()); \curl_setopt($curl, \CURLOPT_USERPWD, $request->uri->getUserInfo());
} }
$cHeaderString = ''; $cHeaderString = '';
@ -128,7 +128,7 @@ final class Rest
} }
$name = \strtolower(\trim($header[0])); $name = \strtolower(\trim($header[0]));
$response->getHeader()->set($name, \trim($header[1])); $response->header->set($name, \trim($header[1]));
return $length; return $length;
} }

View File

@ -24,15 +24,6 @@ namespace phpOMS\Message;
*/ */
interface MessageInterface interface MessageInterface
{ {
/**
* Retrieves all message header values.
*
* @return null|HeaderAbstract
*
* @since 1.0.0
*/
public function getHeader() : ?HeaderAbstract;
/** /**
* Gets the body of the message. * Gets the body of the message.
* *

View File

@ -32,7 +32,7 @@ abstract class RequestAbstract implements MessageInterface
* @var UriInterface * @var UriInterface
* @since 1.0.0 * @since 1.0.0
*/ */
protected UriInterface $uri; public UriInterface $uri;
/** /**
* Request data. * Request data.
@ -64,7 +64,7 @@ abstract class RequestAbstract implements MessageInterface
* @var HeaderAbstract * @var HeaderAbstract
* @since 1.0.0 * @since 1.0.0
*/ */
protected HeaderAbstract $header; public HeaderAbstract $header;
/** /**
* Request hash. * Request hash.
@ -219,18 +219,6 @@ abstract class RequestAbstract implements MessageInterface
$this->lock = true; $this->lock = true;
} }
/**
* Get request header.
*
* @return HeaderAbstract
*
* @since 1.0.0
*/
public function getHeader() : HeaderAbstract
{
return $this->header;
}
/** /**
* Get request language. * Get request language.
* *
@ -240,7 +228,7 @@ abstract class RequestAbstract implements MessageInterface
*/ */
public function getLanguage() : string public function getLanguage() : string
{ {
return $this->header->getL11n()->getLanguage(); return $this->header->l11n->getLanguage();
} }
/** /**
@ -281,16 +269,4 @@ abstract class RequestAbstract implements MessageInterface
{ {
return $this->files; return $this->files;
} }
/**
* Get request uri.
*
* @return UriInterface
*
* @since 1.0.0
*/
public function getUri() : UriInterface
{
return $this->uri;
}
} }

View File

@ -38,7 +38,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface
* @var HeaderAbstract * @var HeaderAbstract
* @since 1.0.0 * @since 1.0.0
*/ */
protected HeaderAbstract $header; public HeaderAbstract $header;
/** /**
* Get response by ID. * Get response by ID.
@ -91,18 +91,6 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface
*/ */
abstract public function toArray() : array; abstract public function toArray() : array;
/**
* Get header.
*
* @return HeaderAbstract
*
* @since 1.0.0
*/
public function getHeader() : HeaderAbstract
{
return $this->header;
}
/** /**
* Get response language. * Get response language.
* *
@ -112,7 +100,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface
*/ */
public function getLanguage() : string public function getLanguage() : string
{ {
return $this->header->getL11n()->getLanguage(); return $this->header->l11n->getLanguage();
} }
/** /**

View File

@ -71,7 +71,7 @@ class PacketManager
public function handle(string $data, $client) : void public function handle(string $data, $client) : void
{ {
$request = new SocketRequest(); $request = new SocketRequest();
$request->getHeader()->setAccount($client->getAccount()->getId()); $request->header->account = $client->getAccount()->getId();
$response = new SocketResponse(); $response = new SocketResponse();

View File

@ -44,7 +44,7 @@ final class Head implements RenderableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $title = ''; public string $title = '';
/** /**
* Assets bound to this page instance. * Assets bound to this page instance.
@ -68,7 +68,7 @@ final class Head implements RenderableInterface
* @var Meta * @var Meta
* @since 1.0.0 * @since 1.0.0
*/ */
private Meta $meta; public Meta $meta;
/** /**
* html style. * html style.
@ -98,44 +98,6 @@ final class Head implements RenderableInterface
$this->meta = new Meta(); $this->meta = new Meta();
} }
/**
* Set page meta.
*
* @return Meta
*
* @since 1.0.0
*/
public function getMeta() : Meta
{
return $this->meta;
}
/**
* Set page title.
*
* @return string
*
* @since 1.0.0
*/
public function getTitle() : string
{
return $this->title;
}
/**
* Set page title.
*
* @param string $title Page title
*
* @return void
*
* @since 1.0.0
*/
public function setTitle(string $title) : void
{
$this->title = $title;
}
/** /**
* Set page title. * Set page title.
* *

View File

@ -41,7 +41,7 @@ final class Meta implements RenderableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $author = ''; public string $author = '';
/** /**
* Charset. * Charset.
@ -57,7 +57,7 @@ final class Meta implements RenderableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $description = ''; public string $description = '';
/** /**
* Itemprop. * Itemprop.
@ -111,32 +111,6 @@ final class Meta implements RenderableInterface
return $this->keywords; return $this->keywords;
} }
/**
* Get author.
*
* @return string Author
*
* @since 1.0.0
*/
public function getAuthor() : string
{
return $this->author;
}
/**
* Set author.
*
* @param string $author Author
*
* @return void
*
* @since 1.0.0
*/
public function setAuthor(string $author) : void
{
$this->author = $author;
}
/** /**
* Get charset. * Get charset.
* *
@ -163,32 +137,6 @@ final class Meta implements RenderableInterface
$this->charset = $charset; $this->charset = $charset;
} }
/**
* Get description.
*
* @return string Descritpion
*
* @since 1.0.0
*/
public function getDescription() : string
{
return $this->description;
}
/**
* Set description.
*
* @param string $description Meta description
*
* @return void
*
* @since 1.0.0
*/
public function setDescription(string $description) : void
{
$this->description = $description;
}
/** /**
* Set property. * Set property.
* *

View File

@ -221,8 +221,8 @@ abstract class ModuleAbstract
$obj $obj
) : void ) : void
{ {
$response->getHeader()->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
$response->set($request->getUri()->__toString(), [ $response->set($request->uri->__toString(), [
'status' => $status, 'status' => $status,
'title' => $title, 'title' => $title,
'message' => $message, 'message' => $message,
@ -243,8 +243,8 @@ abstract class ModuleAbstract
*/ */
protected function fillJsonRawResponse(RequestAbstract $request, ResponseAbstract $response, $obj) : void protected function fillJsonRawResponse(RequestAbstract $request, ResponseAbstract $response, $obj) : void
{ {
$response->getHeader()->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
$response->set($request->getUri()->__toString(), $obj); $response->set($request->uri->__toString(), $obj);
} }
/** /**

View File

@ -253,7 +253,7 @@ class Server extends SocketAbstract
public function shutdown($request) : void public function shutdown($request) : void
{ {
$msg = 'shutdown' . "\n"; $msg = 'shutdown' . "\n";
\socket_write($this->clientManager->get($request->getHeader()->getAccount())->getSocket(), $msg, \strlen($msg)); \socket_write($this->clientManager->get($request->header->account)->getSocket(), $msg, \strlen($msg));
$this->run = false; $this->run = false;
} }

View File

@ -30,7 +30,7 @@ class Address implements \JsonSerializable
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $recipient = ''; public string $recipient = '';
/** /**
* Sub of the address. * Sub of the address.
@ -38,7 +38,7 @@ class Address implements \JsonSerializable
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $fao = ''; public string $fao = '';
/** /**
* Location. * Location.
@ -46,7 +46,7 @@ class Address implements \JsonSerializable
* @var Location * @var Location
* @since 1.0.0 * @since 1.0.0
*/ */
private Location $location; public Location $location;
/** /**
* Constructor. * Constructor.
@ -58,84 +58,6 @@ class Address implements \JsonSerializable
$this->location = new Location(); $this->location = new Location();
} }
/**
* Get recipient.
*
* @return string
*
* @since 1.0.0
*/
public function getRecipient() : string
{
return $this->recipient;
}
/**
* Set recipient.
*
* @param string $recipient Recipient
*
* @return void
*
* @since 1.0.0
*/
public function setRecipient(string $recipient) : void
{
$this->recipient = $recipient;
}
/**
* Get FAO.
*
* @return string
*
* @since 1.0.0
*/
public function getFAO() : string
{
return $this->fao;
}
/**
* Set FAO.
*
* @param string $fao FAO
*
* @return void
*
* @since 1.0.0
*/
public function setFAO(string $fao) : void
{
$this->fao = $fao;
}
/**
* Get location.
*
* @return Location
*
* @since 1.0.0
*/
public function getLocation() : Location
{
return $this->location;
}
/**
* Set location.
*
* @param Location $location Location
*
* @return void
*
* @since 1.0.0
*/
public function setLocation(Location $location) : void
{
$this->location = $location;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -40,7 +40,7 @@ class Location implements \JsonSerializable, \Serializable
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $postal = ''; public string $postal = '';
/** /**
* Name of city. * Name of city.
@ -48,7 +48,7 @@ class Location implements \JsonSerializable, \Serializable
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $city = ''; public string $city = '';
/** /**
* Name of the country. * Name of the country.
@ -64,7 +64,7 @@ class Location implements \JsonSerializable, \Serializable
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $address = ''; public string $address = '';
/** /**
* Address type * Address type
@ -80,7 +80,7 @@ class Location implements \JsonSerializable, \Serializable
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $state = ''; public string $state = '';
/** /**
* Geo coordinates. * Geo coordinates.
@ -128,58 +128,6 @@ class Location implements \JsonSerializable, \Serializable
$this->type = $type; $this->type = $type;
} }
/**
* Get postal or zip code
*
* @return string
*
* @since 1.0.0
*/
public function getPostal() : string
{
return $this->postal;
}
/**
* Set postal or zip code
*
* @param string $postal Postal code
*
* @return void
*
* @since 1.0.0
*/
public function setPostal(string $postal) : void
{
$this->postal = $postal;
}
/**
* Get city name
*
* @return string
*
* @since 1.0.0
*/
public function getCity() : string
{
return $this->city;
}
/**
* Set city name
*
* @param string $city City name
*
* @return void
*
* @since 1.0.0
*/
public function setCity(string $city) : void
{
$this->city = $city;
}
/** /**
* Get country code * Get country code
* *
@ -206,58 +154,6 @@ class Location implements \JsonSerializable, \Serializable
$this->country = $country; $this->country = $country;
} }
/**
* Get address
*
* @return string
*
* @since 1.0.0
*/
public function getAddress() : string
{
return $this->address;
}
/**
* Set address
*
* @param string $address Address
*
* @return void
*
* @since 1.0.0
*/
public function setAddress(string $address) : void
{
$this->address = $address;
}
/**
* Get state name
*
* @return string
*
* @since 1.0.0
*/
public function getState() : string
{
return $this->state;
}
/**
* Set state name
*
* @param string $state State name
*
* @return void
*
* @since 1.0.0
*/
public function setState(string $state) : void
{
$this->state = $state;
}
/** /**
* Get geo location * Get geo location
* *

View File

@ -61,13 +61,13 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer
*/ */
public static function ftpConnect(HttpUri $http) public static function ftpConnect(HttpUri $http)
{ {
$con = \ftp_connect($http->getHost(), $http->getPort(), 10); $con = \ftp_connect($http->host, $http->port, 10);
if ($con === false) { if ($con === false) {
return false; return false;
} }
\ftp_login($con, $http->getUser(), $http->getPass()); \ftp_login($con, $http->user, $http->pass);
if ($http->getPath() !== '') { if ($http->getPath() !== '') {
@\ftp_chdir($con, $http->getPath()); @\ftp_chdir($con, $http->getPath());
@ -620,7 +620,7 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getParent() : ContainerInterface public function getParent(): ContainerInterface
{ {
$uri = clone $this->uri; $uri = clone $this->uri;
$uri->setPath(self::parent($this->path)); $uri->setPath(self::parent($this->path));

View File

@ -77,13 +77,13 @@ class File extends FileAbstract implements FileInterface
*/ */
public static function ftpConnect(HttpUri $http) public static function ftpConnect(HttpUri $http)
{ {
$con = \ftp_connect($http->getHost(), $http->getPort(), 10); $con = \ftp_connect($http->host, $http->port, 10);
if ($con === false) { if ($con === false) {
return false; return false;
} }
\ftp_login($con, $http->getUser(), $http->getPass()); \ftp_login($con, $http->user, $http->pass);
if ($http->getPath() !== '') { if ($http->getPath() !== '') {
@\ftp_chdir($con, $http->getPath()); @\ftp_chdir($con, $http->getPath());

View File

@ -66,7 +66,7 @@ abstract class FileAbstract implements ContainerInterface
* @var \DateTimeImmutable * @var \DateTimeImmutable
* @since 1.0.0 * @since 1.0.0
*/ */
protected \DateTimeImmutable $createdAt; public \DateTimeImmutable $createdAt;
/** /**
* Last changed at. * Last changed at.

View File

@ -68,7 +68,7 @@ final class Argument implements UriInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $scheme = ''; public string $scheme = '';
/** /**
* Uri host. * Uri host.
@ -76,7 +76,7 @@ final class Argument implements UriInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $host = ''; public string $host = '';
/** /**
* Uri port. * Uri port.
@ -84,7 +84,7 @@ final class Argument implements UriInterface
* @var int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
private int $port = 0; public int $port = 0;
/** /**
* Uri user. * Uri user.
@ -92,7 +92,7 @@ final class Argument implements UriInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $user = ''; public string $user = '';
/** /**
* Uri password. * Uri password.
@ -100,7 +100,7 @@ final class Argument implements UriInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $pass = ''; public string $pass = '';
/** /**
* Uri path. * Uri path.
@ -132,7 +132,7 @@ final class Argument implements UriInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $fragment = ''; public string $fragment = '';
/** /**
* Uri base. * Uri base.
@ -280,70 +280,6 @@ final class Argument implements UriInterface
$this->pathOffset = $offset; $this->pathOffset = $offset;
} }
/**
* {@inheritdoc}
*/
public function getScheme() : string
{
return $this->scheme;
}
/**
* {@inheritdoc}
*/
public function setScheme(string $scheme) : void
{
$this->scheme = $scheme;
}
/**
* {@inheritdoc}
*/
public function getHost() : string
{
return $this->host;
}
/**
* {@inheritdoc}
*/
public function setHost(string $host) : void
{
$this->host = $host;
}
/**
* {@inheritdoc}
*/
public function getPort() : int
{
return $this->port;
}
/**
* {@inheritdoc}
*/
public function setPort(int $port) : void
{
$this->port = $port;
}
/**
* {@inheritdoc}
*/
public function getPass() : string
{
return $this->pass;
}
/**
* {@inheritdoc}
*/
public function setPass(string $pass) : void
{
$this->pass = $pass;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -420,22 +356,6 @@ final class Argument implements UriInterface
return $this->query; return $this->query;
} }
/**
* {@inheritdoc}
*/
public function getFragment() : string
{
return $this->fragment;
}
/**
* {@inheritdoc}
*/
public function setFragment(string $fragment) : void
{
$this->fragment = $fragment;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -460,22 +380,6 @@ final class Argument implements UriInterface
return ''; return '';
} }
/**
* {@inheritdoc}
*/
public function getUser() : string
{
return $this->user;
}
/**
* {@inheritdoc}
*/
public function setUser(string $user) : void
{
$this->user = $user;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -68,7 +68,7 @@ final class HttpUri implements UriInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $scheme; public string $scheme;
/** /**
* Uri host. * Uri host.
@ -76,7 +76,7 @@ final class HttpUri implements UriInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $host; public string $host;
/** /**
* Uri port. * Uri port.
@ -84,7 +84,7 @@ final class HttpUri implements UriInterface
* @var int * @var int
* @since 1.0.0 * @since 1.0.0
*/ */
private int $port; public int $port;
/** /**
* Uri user. * Uri user.
@ -92,7 +92,7 @@ final class HttpUri implements UriInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $user; public string $user;
/** /**
* Uri password. * Uri password.
@ -100,7 +100,7 @@ final class HttpUri implements UriInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $pass; public string $pass;
/** /**
* Uri path. * Uri path.
@ -132,7 +132,7 @@ final class HttpUri implements UriInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $fragment; public string $fragment;
/** /**
* Uri base. * Uri base.
@ -271,38 +271,6 @@ final class HttpUri implements UriInterface
$this->pathOffset = $offset; $this->pathOffset = $offset;
} }
/**
* {@inheritdoc}
*/
public function getScheme() : string
{
return $this->scheme;
}
/**
* {@inheritdoc}
*/
public function setScheme(string $scheme) : void
{
$this->scheme = $scheme;
}
/**
* {@inheritdoc}
*/
public function getHost() : string
{
return $this->host;
}
/**
* {@inheritdoc}
*/
public function setHost(string $host) : void
{
$this->host = $host;
}
/** /**
* Return the subdomain of a host * Return the subdomain of a host
* *
@ -322,38 +290,6 @@ final class HttpUri implements UriInterface
return \implode('.', \array_slice($host, 0, $length)); return \implode('.', \array_slice($host, 0, $length));
} }
/**
* {@inheritdoc}
*/
public function getPort() : int
{
return $this->port;
}
/**
* {@inheritdoc}
*/
public function setPort(int $port) : void
{
$this->port = $port;
}
/**
* {@inheritdoc}
*/
public function getPass() : string
{
return $this->pass;
}
/**
* {@inheritdoc}
*/
public function setPass(string $pass) : void
{
$this->pass = $pass;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -430,22 +366,6 @@ final class HttpUri implements UriInterface
return $this->query; return $this->query;
} }
/**
* {@inheritdoc}
*/
public function getFragment() : string
{
return $this->fragment;
}
/**
* {@inheritdoc}
*/
public function setFragment(string $fragment) : void
{
$this->fragment = $fragment;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -467,24 +387,8 @@ final class HttpUri implements UriInterface
*/ */
public function getAuthority() : string public function getAuthority() : string
{ {
return ($this->getUser() !== '' ? $this->getUser() . '@' : '') . $this->host return ($this->user !== '' ? $this->user . '@' : '') . $this->host
. ($this->port !== null && $this->port !== 0 ? ':' . $this->port : ''); . ($this->port !== 0 ? ':' . $this->port : '');
}
/**
* {@inheritdoc}
*/
public function getUser() : string
{
return $this->user;
}
/**
* {@inheritdoc}
*/
public function setUser(string $user) : void
{
$this->user = $user;
} }
/** /**

View File

@ -113,17 +113,17 @@ final class UriFactory
*/ */
public static function setupUriBuilder(UriInterface $uri) : void public static function setupUriBuilder(UriInterface $uri) : void
{ {
self::setQuery('/scheme', $uri->getScheme()); self::setQuery('/scheme', $uri->scheme);
self::setQuery('/host', $uri->getHost()); self::setQuery('/host', $uri->host);
self::setQuery('/port', (string) $uri->getPort()); self::setQuery('/port', (string) $uri->port);
self::setQuery('/base', \rtrim($uri->getBase(), '/')); self::setQuery('/base', \rtrim($uri->getBase(), '/'));
self::setQuery('/rootPath', $uri->getRootPath()); self::setQuery('/rootPath', $uri->getRootPath());
self::setQuery('?', '?' . $uri->getQuery()); self::setQuery('?', '?' . $uri->getQuery());
self::setQuery('%', $uri->__toString()); self::setQuery('%', $uri->__toString());
self::setQuery('#', $uri->getFragment()); self::setQuery('#', $uri->fragment);
self::setQuery('/', $uri->getPath()); self::setQuery('/', $uri->getPath());
self::setQuery(':user', $uri->getUser()); self::setQuery(':user', $uri->user);
self::setQuery(':pass', $uri->getPass()); self::setQuery(':pass', $uri->pass);
$data = $uri->getPathElements(); $data = $uri->getPathElements();
foreach ($data as $key => $value) { foreach ($data as $key => $value) {

View File

@ -35,26 +35,6 @@ interface UriInterface
*/ */
public static function isValid(string $uri) : bool; public static function isValid(string $uri) : bool;
/**
* Get scheme.
*
* @return string
*
* @since 1.0.0
*/
public function getScheme() : string;
/**
* Set scheme.
*
* @param string $scheme Path
*
* @return void
*
* @since 1.0.0
*/
public function setScheme(string $scheme) : void;
/** /**
* Get authority. * Get authority.
* *
@ -73,46 +53,6 @@ interface UriInterface
*/ */
public function getUserInfo() : string; public function getUserInfo() : string;
/**
* Get host.
*
* @return string
*
* @since 1.0.0
*/
public function getHost() : string;
/**
* Set host.
*
* @param string $host Host
*
* @return void
*
* @since 1.0.0
*/
public function setHost(string $host) : void;
/**
* Get port.
*
* @return int
*
* @since 1.0.0
*/
public function getPort() : int;
/**
* Set port.
*
* @param int $port Port
*
* @return void
*
* @since 1.0.0
*/
public function setPort(int $port) : void;
/** /**
* Get path. * Get path.
* *
@ -133,46 +73,6 @@ interface UriInterface
*/ */
public function setPath(string $path) : void; public function setPath(string $path) : void;
/**
* Get user.
*
* @return string
*
* @since 1.0.0
*/
public function getUser() : string;
/**
* Set user.
*
* @param string $user User
*
* @return void
*
* @since 1.0.0
*/
public function setUser(string $user) : void;
/**
* Get password.
*
* @return string
*
* @since 1.0.0
*/
public function getPass() : string;
/**
* Set pass.
*
* @param string $pass Pass
*
* @return void
*
* @since 1.0.0
*/
public function setPass(string $pass) : void;
/** /**
* Get root path. * Get root path.
* *
@ -246,26 +146,6 @@ interface UriInterface
*/ */
public function getQueryArray() : array; public function getQueryArray() : array;
/**
* Get fragment.
*
* @return string
*
* @since 1.0.0
*/
public function getFragment() : string;
/**
* Set fragment.
*
* @param string $fragment Fragment
*
* @return void
*
* @since 1.0.0
*/
public function setFragment(string $fragment) : void;
/** /**
* Get uri. * Get uri.
* *

View File

@ -30,7 +30,7 @@ class Author
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Email. * Email.
@ -78,18 +78,6 @@ class Author
$this->email = $email; $this->email = $email;
} }
/**
* Get name
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/** /**
* Get email * Get email
* *

View File

@ -30,7 +30,7 @@ class Branch
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Constructor * Constructor
@ -44,18 +44,6 @@ class Branch
$this->setName($name); $this->setName($name);
} }
/**
* Get name
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/** /**
* Set branch name * Set branch name
* *

View File

@ -42,7 +42,7 @@ class Repository
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Bare repository. * Bare repository.

View File

@ -30,7 +30,7 @@ class Tag
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Message. * Message.

View File

@ -61,7 +61,7 @@ class View extends ViewAbstract
* @var null|RequestAbstract * @var null|RequestAbstract
* @since 1.0.0 * @since 1.0.0
*/ */
protected ?RequestAbstract $request; public ?RequestAbstract $request;
/** /**
* Request. * Request.
@ -69,7 +69,7 @@ class View extends ViewAbstract
* @var null|ResponseAbstract * @var null|ResponseAbstract
* @since 1.0.0 * @since 1.0.0
*/ */
protected ?ResponseAbstract $response; public ?ResponseAbstract $response;
/** /**
* Theme name. * Theme name.
@ -101,7 +101,7 @@ class View extends ViewAbstract
$this->l11nManager = $l11n ?? new L11nManager('Error'); $this->l11nManager = $l11n ?? new L11nManager('Error');
$this->request = $request; $this->request = $request;
$this->response = $response; $this->response = $response;
$this->l11n = $response !== null ? $response->getHeader()->getL11n() : new Localization(); $this->l11n = $response !== null ? $response->header->l11n : new Localization();
} }
/** /**
@ -355,28 +355,4 @@ class View extends ViewAbstract
{ {
return $this->l11nManager->getDateTime($this->l11n, $datetime, $format); return $this->l11nManager->getDateTime($this->l11n, $datetime, $format);
} }
/**
* Get request of view
*
* @return null|RequestAbstract
*
* @since 1.0.0
*/
public function getRequest() : ?RequestAbstract
{
return $this->request;
}
/**
* Get response of view
*
* @return null|ResponseAbstract
*
* @since 1.0.0
*/
public function getResponse() : ?ResponseAbstract
{
return $this->response;
}
} }

View File

@ -63,7 +63,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
self::assertObjectHasAttribute('groups', $account); self::assertObjectHasAttribute('groups', $account);
self::assertObjectHasAttribute('type', $account); self::assertObjectHasAttribute('type', $account);
self::assertObjectHasAttribute('status', $account); self::assertObjectHasAttribute('status', $account);
self::assertObjectHasAttribute('localization', $account); self::assertObjectHasAttribute('l11n', $account);
} }
/** /**
@ -79,20 +79,20 @@ class AccountTest extends \PHPUnit\Framework\TestCase
self::assertIsInt($account->getId()); self::assertIsInt($account->getId());
self::assertEquals(0, $account->getId()); self::assertEquals(0, $account->getId());
self::assertInstanceOf('\phpOMS\Localization\Localization', $account->getL11n()); self::assertInstanceOf('\phpOMS\Localization\Localization', $account->l11n);
self::assertEquals([], $account->getGroups()); self::assertEquals([], $account->getGroups());
self::assertNull($account->getName()); self::assertNull($account->login);
self::assertIsString($account->getName1()); self::assertIsString($account->name1);
self::assertEquals('', $account->getName1()); self::assertEquals('', $account->name1);
self::assertIsString($account->getName2()); self::assertIsString($account->name2);
self::assertEquals('', $account->getName2()); self::assertEquals('', $account->name2);
self::assertIsString($account->getName3()); self::assertIsString($account->name3);
self::assertEquals('', $account->getName3()); self::assertEquals('', $account->name3);
self::assertIsString($account->getEmail()); self::assertIsString($account->getEmail());
self::assertEquals('', $account->getEmail()); self::assertEquals('', $account->getEmail());
@ -106,7 +106,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
self::assertEquals([], $account->getPermissions()); self::assertEquals([], $account->getPermissions());
self::assertInstanceOf('\DateTimeInterface', $account->getLastActive()); self::assertInstanceOf('\DateTimeInterface', $account->getLastActive());
self::assertInstanceOf('\DateTimeImmutable', $account->getCreatedAt()); self::assertInstanceOf('\DateTimeImmutable', $account->createdAt);
$array = $account->toArray(); $array = $account->toArray();
self::assertIsArray($array); self::assertIsArray($array);
@ -125,20 +125,17 @@ class AccountTest extends \PHPUnit\Framework\TestCase
$account = new Account(); $account = new Account();
$account->generatePassword('abcd'); $account->generatePassword('abcd');
$account->setName('Login'); $account->login = 'Login';
self::assertEquals('Login', $account->getName()); self::assertEquals('Login', $account->login);
$account->setName1('Donald'); $account->name1 = 'Donald';
self::assertEquals('Donald', $account->getName1()); self::assertEquals('Donald', $account->name1);
$account->setName2('Fauntleroy'); $account->name2 = 'Fauntleroy';
self::assertEquals('Fauntleroy', $account->getName2()); self::assertEquals('Fauntleroy', $account->name2);
$account->setName3('Duck'); $account->name3 = 'Duck';
self::assertEquals('Duck', $account->getName3()); self::assertEquals('Duck', $account->name3);
$account->setName('Login');
self::assertEquals('Login', $account->getName());
} }
/** /**
@ -276,8 +273,8 @@ class AccountTest extends \PHPUnit\Framework\TestCase
$account = new Account(); $account = new Account();
$account->generatePassword('abcd'); $account->generatePassword('abcd');
$account->setL11n(new Localization()); $account->l11n = new Localization();
self::assertInstanceOf('\phpOMS\Localization\Localization', $account->getL11n()); self::assertInstanceOf('\phpOMS\Localization\Localization', $account->l11n);
} }
/** /**

View File

@ -61,14 +61,14 @@ class GroupTest extends \PHPUnit\Framework\TestCase
self::assertIsInt($group->getId()); self::assertIsInt($group->getId());
self::assertEquals(0, $group->getId()); self::assertEquals(0, $group->getId());
self::assertIsString($group->getName()); self::assertIsString($group->name);
self::assertEquals('', $group->getName()); self::assertEquals('', $group->name);
self::assertIsInt($group->getStatus()); self::assertIsInt($group->getStatus());
self::assertEquals(GroupStatus::INACTIVE, $group->getStatus()); self::assertEquals(GroupStatus::INACTIVE, $group->getStatus());
self::assertIsString($group->getDescription()); self::assertIsString($group->description);
self::assertEquals('', $group->getDescription()); self::assertEquals('', $group->description);
$array = $group->toArray(); $array = $group->toArray();
self::assertIsArray($array); self::assertIsArray($array);
@ -86,11 +86,11 @@ class GroupTest extends \PHPUnit\Framework\TestCase
{ {
$group = new Group(); $group = new Group();
$group->setName('Duck'); $group->name = 'Duck';
self::assertEquals('Duck', $group->getName()); self::assertEquals('Duck', $group->name);
$group->setDescription('Animal'); $group->description = 'Animal';
self::assertEquals('Animal', $group->getDescription()); self::assertEquals('Animal', $group->description);
} }
/** /**

View File

@ -47,13 +47,13 @@ class KmeansTest extends \PHPUnit\Framework\TestCase
$kmeans = new Kmeans($points, 2); $kmeans = new Kmeans($points, 2);
if ($kmeans->cluster($points[0])->getGroup() === 0 if ($kmeans->cluster($points[0])->group === 0
&& $kmeans->cluster($points[1])->getGroup() === 0 && $kmeans->cluster($points[1])->group === 0
&& $kmeans->cluster($points[2])->getGroup() === 1 && $kmeans->cluster($points[2])->group === 1
&& $kmeans->cluster($points[3])->getGroup() === 1 && $kmeans->cluster($points[3])->group === 1
&& $kmeans->cluster($points[4])->getGroup() === 1 && $kmeans->cluster($points[4])->group === 1
&& $kmeans->cluster($points[5])->getGroup() === 1 && $kmeans->cluster($points[5])->group === 1
&& $kmeans->cluster($points[6])->getGroup() === 1 && $kmeans->cluster($points[6])->group === 1
) { ) {
$result = true; $result = true;

View File

@ -35,8 +35,8 @@ class PointTest extends \PHPUnit\Framework\TestCase
self::assertEquals([3.0, 2.0], $point->getCoordinates()); self::assertEquals([3.0, 2.0], $point->getCoordinates());
self::assertEquals(3.0, $point->getCoordinate(0)); self::assertEquals(3.0, $point->getCoordinate(0));
self::assertEquals(2.0, $point->getCoordinate(1)); self::assertEquals(2.0, $point->getCoordinate(1));
self::assertEquals(0, $point->getGroup()); self::assertEquals(0, $point->group);
self::assertEquals('abc', $point->getName()); self::assertEquals('abc', $point->name);
} }
/** /**
@ -65,8 +65,8 @@ class PointTest extends \PHPUnit\Framework\TestCase
{ {
$point = new Point([3.0, 2.0], 'abc'); $point = new Point([3.0, 2.0], 'abc');
$point->setGroup(2); $point->group = 2;
self::assertEquals(2, $point->getGroup()); self::assertEquals(2, $point->group);
} }
/** /**
@ -78,7 +78,7 @@ class PointTest extends \PHPUnit\Framework\TestCase
{ {
$point = new Point([3.0, 2.0], 'abc'); $point = new Point([3.0, 2.0], 'abc');
$point->setName('xyz'); $point->name = 'xyz';
self::assertEquals('xyz', $point->getName()); self::assertEquals('xyz', $point->name);
} }
} }

View File

@ -35,6 +35,6 @@ class JobTest extends \PHPUnit\Framework\TestCase
self::assertEquals(3.0, $item->getValue()); self::assertEquals(3.0, $item->getValue());
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $item->getStart()->format('Y-m-d')); self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $item->getStart()->format('Y-m-d'));
self::assertNull($item->getEnd()); self::assertNull($item->getEnd());
self::assertEquals('abc', $item->getName()); self::assertEquals('abc', $item->name);
} }
} }

View File

@ -47,7 +47,7 @@ class WeightedTest extends \PHPUnit\Framework\TestCase
foreach ($filtered as $job) { foreach ($filtered as $job) {
$value += $job->getValue(); $value += $job->getValue();
$names[] = $job->getName(); $names[] = $job->name;
} }
self::assertEqualsWithDelta(350, $value, 0.01); self::assertEqualsWithDelta(350, $value, 0.01);

View File

@ -78,7 +78,7 @@ class GridTest extends \PHPUnit\Framework\TestCase
], Node::class); ], Node::class);
$grid->setNode(0, 0, new Node(0, 0, 1.0, false)); $grid->setNode(0, 0, new Node(0, 0, 1.0, false));
self::assertFalse($grid->getNode(0, 0)->isWalkable()); self::assertFalse($grid->getNode(0, 0)->isWalkable);
self::assertFalse($grid->isWalkable(0, 0)); self::assertFalse($grid->isWalkable(0, 0));
} }

View File

@ -38,8 +38,8 @@ class NodeTest extends \PHPUnit\Framework\TestCase
self::assertEquals(2, $node->getY()); self::assertEquals(2, $node->getY());
self::assertEquals(['x' => 1, 'y' => 2], $node->getCoordinates()); self::assertEquals(['x' => 1, 'y' => 2], $node->getCoordinates());
self::assertEquals(3.0, $node->getWeight()); self::assertEquals(3.0, $node->getWeight());
self::assertNull($node->getParent()); self::assertNull($node->parent);
self::assertFalse($node->isWalkable()); self::assertFalse($node->isWalkable);
} }
/** /**
@ -78,7 +78,7 @@ class NodeTest extends \PHPUnit\Framework\TestCase
$node = new Node(1, 2, 3.0, false); $node = new Node(1, 2, 3.0, false);
$node2 = new Node(2, 2, 3.0, false); $node2 = new Node(2, 2, 3.0, false);
$node->setParent($node2); $node->parent = $node2;
self::assertTrue($node2->isEqual($node->getParent())); self::assertTrue($node2->isEqual($node->parent));
} }
} }

View File

@ -274,43 +274,49 @@ $CONFIG = [
]; ];
// Reset database // Reset database
try { if (\extension_loaded('pdo_mysql')) {
$db = new \PDO($CONFIG['db']['core']['masters']['admin']['db'] . ':host=' . try {
$CONFIG['db']['core']['masters']['admin']['host'], $db = new \PDO($CONFIG['db']['core']['masters']['admin']['db'] . ':host=' .
$CONFIG['db']['core']['masters']['admin']['login'], $CONFIG['db']['core']['masters']['admin']['host'],
$CONFIG['db']['core']['masters']['admin']['password'] $CONFIG['db']['core']['masters']['admin']['login'],
); $CONFIG['db']['core']['masters']['admin']['password']
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']); );
$db->exec('CREATE DATABASE IF NOT EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']); $db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
$db = null; $db->exec('CREATE DATABASE IF NOT EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
} catch (\Throwable $t) { $db = null;
echo "\nCouldn't connect to MYSQL DB\n"; } catch (\Throwable $t) {
echo "\nCouldn't connect to MYSQL DB\n";
}
} }
try { if (\extension_loaded('pdo_pgsql')) {
$db = new \PDO($CONFIG['db']['core']['postgresql']['admin']['db'] . ':host=' . try {
$CONFIG['db']['core']['postgresql']['admin']['host'], $db = new \PDO($CONFIG['db']['core']['postgresql']['admin']['db'] . ':host=' .
$CONFIG['db']['core']['postgresql']['admin']['login'], $CONFIG['db']['core']['postgresql']['admin']['host'],
$CONFIG['db']['core']['postgresql']['admin']['password'] $CONFIG['db']['core']['postgresql']['admin']['login'],
); $CONFIG['db']['core']['postgresql']['admin']['password']
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['postgresql']['admin']['database']); );
$db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['postgresql']['admin']['database']); $db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['postgresql']['admin']['database']);
$db = null; $db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['postgresql']['admin']['database']);
} catch (\Throwable $t) { $db = null;
echo "\nCouldn't connect to POSTGRESQL DB\n"; } catch (\Throwable $t) {
echo "\nCouldn't connect to POSTGRESQL DB\n";
}
} }
try { if (\extension_loaded('pdo_sqlsrv')) {
$db = new \PDO($CONFIG['db']['core']['mssql']['admin']['db'] . ':host=' . try {
$CONFIG['db']['core']['mssql']['admin']['host'], $db = new \PDO($CONFIG['db']['core']['mssql']['admin']['db'] . ':host=' .
$CONFIG['db']['core']['mssql']['admin']['login'], $CONFIG['db']['core']['mssql']['admin']['host'],
$CONFIG['db']['core']['mssql']['admin']['password'] $CONFIG['db']['core']['mssql']['admin']['login'],
); $CONFIG['db']['core']['mssql']['admin']['password']
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['mssql']['admin']['database']); );
$db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['mssql']['admin']['database']); $db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['mssql']['admin']['database']);
$db = null; $db->exec('CREATE DATABASE ' . $CONFIG['db']['core']['mssql']['admin']['database']);
} catch (\Throwable $t) { $db = null;
echo "\nCouldn't connect to MSSQL DB\n"; } catch (\Throwable $t) {
echo "\nCouldn't connect to MSSQL DB\n";
}
} }
$httpSession = new HttpSession(); $httpSession = new HttpSession();

View File

@ -126,7 +126,7 @@ class EventManagerTest extends \PHPUnit\Framework\TestCase
$this->event->addGroup('group', 'id1'); $this->event->addGroup('group', 'id1');
$this->event->addGroup('group', 'id2'); $this->event->addGroup('group', 'id2');
self::assertTrue($this->event->triggerSimilar('/[a-z]+/', '/id\d/')); self::assertTrue($this->event->triggerSimilar('/[a-z]+/', '/id\\d/'));
} }
/** /**
@ -140,7 +140,7 @@ class EventManagerTest extends \PHPUnit\Framework\TestCase
$this->event->addGroup('group', 'id1'); $this->event->addGroup('group', 'id1');
$this->event->addGroup('group', 'id2'); $this->event->addGroup('group', 'id2');
self::assertTrue($this->event->triggerSimilar('group', '/id\d/')); self::assertTrue($this->event->triggerSimilar('group', '/id\\d/'));
} }
/** /**
@ -169,7 +169,7 @@ class EventManagerTest extends \PHPUnit\Framework\TestCase
$this->event->addGroup('group', 'id1'); $this->event->addGroup('group', 'id1');
$this->event->addGroup('group', 'id2'); $this->event->addGroup('group', 'id2');
self::assertFalse($this->event->triggerSimilar('group', '/id\d0/')); self::assertFalse($this->event->triggerSimilar('group', '/id\\d0/'));
} }
/** /**

View File

@ -47,7 +47,7 @@ class LocalizationTest extends \PHPUnit\Framework\TestCase
{ {
self::assertObjectHasAttribute('country', $this->localization); self::assertObjectHasAttribute('country', $this->localization);
self::assertObjectHasAttribute('timezone', $this->localization); self::assertObjectHasAttribute('timezone', $this->localization);
self::assertObjectHasAttribute('lang', $this->localization); self::assertObjectHasAttribute('language', $this->localization);
self::assertObjectHasAttribute('currency', $this->localization); self::assertObjectHasAttribute('currency', $this->localization);
self::assertObjectHasAttribute('decimal', $this->localization); self::assertObjectHasAttribute('decimal', $this->localization);
self::assertObjectHasAttribute('thousands', $this->localization); self::assertObjectHasAttribute('thousands', $this->localization);

View File

@ -36,13 +36,13 @@ class ConsoleHeaderTest extends \PHPUnit\Framework\TestCase
public function testDefaults() : void public function testDefaults() : void
{ {
self::assertFalse($this->header->isLocked()); self::assertFalse($this->header->isLocked());
self::assertEquals(0, $this->header->getStatusCode()); self::assertEquals(0, $this->header->status);
self::assertEquals('1.0', $this->header->getProtocolVersion()); self::assertEquals('1.0', $this->header->getProtocolVersion());
self::assertEquals('', $this->header->getReasonPhrase()); self::assertEquals('', $this->header->getReasonPhrase());
self::assertEquals([], $this->header->get('key')); self::assertEquals([], $this->header->get('key'));
self::assertFalse($this->header->has('key')); self::assertFalse($this->header->has('key'));
self::assertInstanceOf(Localization::class, $this->header->getL11n()); self::assertInstanceOf(Localization::class, $this->header->l11n);
self::assertEquals(0, $this->header->getAccount()); self::assertEquals(0, $this->header->account);
} }
/** /**
@ -105,8 +105,8 @@ class ConsoleHeaderTest extends \PHPUnit\Framework\TestCase
*/ */
public function testAccount() : void public function testAccount() : void
{ {
$this->header->setAccount(2); $this->header->account = 2;
self::AssertEquals(2, $this->header->getAccount(2)); self::AssertEquals(2, $this->header->account);
} }
/** /**

View File

@ -43,7 +43,7 @@ class ConsoleRequestTest extends \PHPUnit\Framework\TestCase
self::assertEquals(OSType::LINUX, $request->getOS()); self::assertEquals(OSType::LINUX, $request->getOS());
self::assertEquals('127.0.0.1', $request->getOrigin()); self::assertEquals('127.0.0.1', $request->getOrigin());
self::assertEmpty($request->getBody()); self::assertEmpty($request->getBody());
self::assertInstanceOf('\phpOMS\Message\Console\ConsoleHeader', $request->getHeader()); self::assertInstanceOf('\phpOMS\Message\Console\ConsoleHeader', $request->header);
self::assertEquals('', $request->__toString()); self::assertEquals('', $request->__toString());
self::assertFalse($request->hasData('key')); self::assertFalse($request->hasData('key'));
self::assertNull($request->getData('key')); self::assertNull($request->getData('key'));
@ -75,7 +75,7 @@ class ConsoleRequestTest extends \PHPUnit\Framework\TestCase
*/ */
public function testInputOutputUriString() : void public function testInputOutputUriString() : void
{ {
self::assertEquals('get:some/test/path', $this->request->getUri()->__toString()); self::assertEquals('get:some/test/path', $this->request->uri->__toString());
} }
/** /**
@ -85,7 +85,7 @@ class ConsoleRequestTest extends \PHPUnit\Framework\TestCase
public function testInputOutputL11n() : void public function testInputOutputL11n() : void
{ {
$l11n = new Localization(); $l11n = new Localization();
self::assertEquals($l11n, $this->request->getHeader()->getL11n()); self::assertEquals($l11n, $this->request->header->l11n);
} }
/** /**

View File

@ -32,8 +32,8 @@ class ConsoleResponseTest extends \PHPUnit\Framework\TestCase
self::assertEquals('', $response->getBody()); self::assertEquals('', $response->getBody());
self::assertEquals('', $response->render()); self::assertEquals('', $response->render());
self::assertEquals([], $response->toArray()); self::assertEquals([], $response->toArray());
self::assertInstanceOf('\phpOMS\Localization\Localization', $response->getHeader()->getL11n()); self::assertInstanceOf('\phpOMS\Localization\Localization', $response->header->l11n);
self::assertInstanceOf('\phpOMS\Message\Console\ConsoleHeader', $response->getHeader()); self::assertInstanceOf('\phpOMS\Message\Console\ConsoleHeader', $response->header);
} }
/** /**

View File

@ -64,7 +64,7 @@ class HeaderAbstractTest extends \PHPUnit\Framework\TestCase
*/ */
public function testStatusCodeInputOutput() : void public function testStatusCodeInputOutput() : void
{ {
$this->header->setStatusCode(2); $this->header->status = 2;
self::assertEquals(2, $this->header->getStatusCode()); self::assertEquals(2, $this->header->status);
} }
} }

View File

@ -41,14 +41,14 @@ class HttpHeaderTest extends \PHPUnit\Framework\TestCase
public function testDefaults() : void public function testDefaults() : void
{ {
self::assertFalse($this->header->isLocked()); self::assertFalse($this->header->isLocked());
self::assertEquals(RequestStatusCode::R_200, $this->header->getStatusCode()); self::assertEquals(RequestStatusCode::R_200, $this->header->status);
self::assertEquals('HTTP/1.1', $this->header->getProtocolVersion()); self::assertEquals('HTTP/1.1', $this->header->getProtocolVersion());
self::assertEmpty(HttpHeader::getAllHeaders()); self::assertEmpty(HttpHeader::getAllHeaders());
self::assertEquals('', $this->header->getReasonPhrase()); self::assertEquals('', $this->header->getReasonPhrase());
self::assertEquals([], $this->header->get('key')); self::assertEquals([], $this->header->get('key'));
self::assertFalse($this->header->has('key')); self::assertFalse($this->header->has('key'));
self::assertInstanceOf(Localization::class, $this->header->getL11n()); self::assertInstanceOf(Localization::class, $this->header->l11n);
self::assertEquals(0, $this->header->getAccount()); self::assertEquals(0, $this->header->account);
} }
/** /**
@ -130,8 +130,8 @@ class HttpHeaderTest extends \PHPUnit\Framework\TestCase
*/ */
public function testAccountInputOutput() : void public function testAccountInputOutput() : void
{ {
$this->header->setAccount(2); $this->header->account = 2;
self::assertEquals(2, $this->header->getAccount(2)); self::assertEquals(2, $this->header->account);
} }
/** /**

View File

@ -53,7 +53,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
self::assertEmpty($request->getFiles()); self::assertEmpty($request->getFiles());
self::assertEquals(RouteVerb::GET, $request->getRouteVerb()); self::assertEquals(RouteVerb::GET, $request->getRouteVerb());
self::assertEquals(RequestMethod::GET, $request->getMethod()); self::assertEquals(RequestMethod::GET, $request->getMethod());
self::assertInstanceOf('\phpOMS\Message\Http\HttpHeader', $request->getHeader()); self::assertInstanceOf('\phpOMS\Message\Http\HttpHeader', $request->header);
self::assertInstanceOf('\phpOMS\Message\Http\HttpRequest', HttpRequest::createFromSuperglobals()); self::assertInstanceOf('\phpOMS\Message\Http\HttpRequest', HttpRequest::createFromSuperglobals());
self::assertEquals('http://', $request->__toString()); self::assertEquals('http://', $request->__toString());
self::assertFalse($request->hasData('key')); self::assertFalse($request->hasData('key'));
@ -152,7 +152,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3',
'328413d996ab9b79af9d4098af3a65b885c4ca64', '328413d996ab9b79af9d4098af3a65b885c4ca64',
], $request->getHash()); ], $request->getHash());
self::assertEquals($l11n, $request->getHeader()->getL11n()); self::assertEquals($l11n, $request->header->l11n);
} }
/** /**
@ -388,7 +388,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
{ {
$request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestPost.php')); $request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestPost.php'));
$request->setMethod(RequestMethod::POST); $request->setMethod(RequestMethod::POST);
$request->getHeader()->set('Content-Type', MimeType::M_POST); $request->header->set('Content-Type', MimeType::M_POST);
$request->setData('testKey', 'testValue'); $request->setData('testKey', 'testValue');
self::assertEquals( self::assertEquals(
@ -406,7 +406,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
{ {
$request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestPost.php')); $request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestPost.php'));
$request->setMethod(RequestMethod::POST); $request->setMethod(RequestMethod::POST);
$request->getHeader()->set('Content-Type', MimeType::M_JSON); $request->header->set('Content-Type', MimeType::M_JSON);
$request->setData('testKey', 'testValue'); $request->setData('testKey', 'testValue');
self::assertEquals( self::assertEquals(
@ -424,7 +424,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
{ {
$request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestPost.php')); $request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestPost.php'));
$request->setMethod(RequestMethod::POST); $request->setMethod(RequestMethod::POST);
$request->getHeader()->set('Content-Type', MimeType::M_MULT); $request->header->set('Content-Type', MimeType::M_MULT);
$request->setData('testKey', 'testValue'); $request->setData('testKey', 'testValue');
self::assertEquals( self::assertEquals(

View File

@ -41,8 +41,8 @@ class ResponseTest extends \PHPUnit\Framework\TestCase
self::assertEquals('', $this->response->getBody()); self::assertEquals('', $this->response->getBody());
self::assertEquals('', $this->response->render()); self::assertEquals('', $this->response->render());
self::assertEquals([], $this->response->toArray()); self::assertEquals([], $this->response->toArray());
self::assertInstanceOf('\phpOMS\Localization\Localization', $this->response->getHeader()->getL11n()); self::assertInstanceOf('\phpOMS\Localization\Localization', $this->response->header->l11n);
self::assertInstanceOf('\phpOMS\Message\Http\HttpHeader', $this->response->getHeader()); self::assertInstanceOf('\phpOMS\Message\Http\HttpHeader', $this->response->header);
} }
/** /**
@ -155,7 +155,7 @@ class ResponseTest extends \PHPUnit\Framework\TestCase
}); });
$this->response->set('null', null); $this->response->set('null', null);
$this->response->getHeader()->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); $this->response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
self::assertEquals(\json_encode($data), $this->response->render()); self::assertEquals(\json_encode($data), $this->response->render());
} }
@ -186,7 +186,7 @@ class ResponseTest extends \PHPUnit\Framework\TestCase
} }
}); });
$this->response->getHeader()->set('Content-Type', MimeType::M_HTML . '; charset=utf-8', true); $this->response->header->set('Content-Type', MimeType::M_HTML . '; charset=utf-8', true);
self::assertEquals('view_string with <div> text</div> that has whitespaces and new lines', $this->response->render(true)); self::assertEquals('view_string with <div> text</div> that has whitespaces and new lines', $this->response->render(true));
} }
@ -204,7 +204,7 @@ class ResponseTest extends \PHPUnit\Framework\TestCase
} }
}); });
$this->response->getHeader()->set('Content-Type', MimeType::M_TEXT . '; charset=utf-8', true); $this->response->header->set('Content-Type', MimeType::M_TEXT . '; charset=utf-8', true);
self::assertEquals(" view_string with <div> text</div> that has \n whitespaces and \n\nnew lines\n ", $this->response->render(true)); self::assertEquals(" view_string with <div> text</div> that has \n whitespaces and \n\nnew lines\n ", $this->response->render(true));
} }

View File

@ -38,8 +38,8 @@ class HeadTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDefault() : void public function testDefault() : void
{ {
self::assertInstanceOf('\phpOMS\Model\Html\Meta', $this->head->getMeta()); self::assertInstanceOf('\phpOMS\Model\Html\Meta', $this->head->meta);
self::assertEquals('', $this->head->getTitle()); self::assertEquals('', $this->head->title);
self::assertEquals('en', $this->head->getLanguage()); self::assertEquals('en', $this->head->getLanguage());
self::assertEquals([], $this->head->getStyleAll()); self::assertEquals([], $this->head->getStyleAll());
self::assertEquals([], $this->head->getScriptAll()); self::assertEquals([], $this->head->getScriptAll());
@ -57,8 +57,8 @@ class HeadTest extends \PHPUnit\Framework\TestCase
*/ */
public function testTitleInputOutput() : void public function testTitleInputOutput() : void
{ {
$this->head->setTitle('my title'); $this->head->title = 'my title';
self::assertEquals('my title', $this->head->getTitle()); self::assertEquals('my title', $this->head->title);
} }
/** /**

View File

@ -37,9 +37,9 @@ class MetaTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDefault() : void public function testDefault() : void
{ {
self::assertEquals('', $this->meta->getDescription()); self::assertEquals('', $this->meta->description);
self::assertEquals('', $this->meta->getCharset()); self::assertEquals('', $this->meta->getCharset());
self::assertEquals('', $this->meta->getAuthor()); self::assertEquals('', $this->meta->author);
self::assertEquals('', $this->meta->getName('')); self::assertEquals('', $this->meta->getName(''));
self::assertEquals('', $this->meta->getProperty('')); self::assertEquals('', $this->meta->getProperty(''));
self::assertEquals('', $this->meta->getItemprop('')); self::assertEquals('', $this->meta->getItemprop(''));
@ -65,8 +65,8 @@ class MetaTest extends \PHPUnit\Framework\TestCase
*/ */
public function testAuthorInputOutput() : void public function testAuthorInputOutput() : void
{ {
$this->meta->setAuthor('oms'); $this->meta->author = 'oms';
self::assertEquals('oms', $this->meta->getAuthor()); self::assertEquals('oms', $this->meta->author);
} }
/** /**
@ -87,8 +87,8 @@ class MetaTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDescriptionInputOutput() : void public function testDescriptionInputOutput() : void
{ {
$this->meta->setDescription('some description'); $this->meta->description = 'some description';
self::assertEquals('some description', $this->meta->getDescription()); self::assertEquals('some description', $this->meta->description);
} }
/** /**
@ -132,9 +132,9 @@ class MetaTest extends \PHPUnit\Framework\TestCase
public function testRender() : void public function testRender() : void
{ {
$this->meta->addKeyword('orange'); $this->meta->addKeyword('orange');
$this->meta->setAuthor('oms'); $this->meta->author = 'oms';
$this->meta->setCharset('utf-8'); $this->meta->setCharset('utf-8');
$this->meta->setDescription('some description'); $this->meta->description = 'some description';
$this->meta->setProperty('og:title', 'TestProperty'); $this->meta->setProperty('og:title', 'TestProperty');
$this->meta->setItemprop('title', 'TestItemprop'); $this->meta->setItemprop('title', 'TestItemprop');
$this->meta->setName('title', 'TestName'); $this->meta->setName('title', 'TestName');

View File

@ -50,7 +50,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
{ {
self::assertEmpty( self::assertEmpty(
$this->router->route( $this->router->route(
(new HttpRequest(new HttpUri('')))->getUri()->getRoute() (new HttpRequest(new HttpUri('')))->uri->getRoute()
) )
); );
} }
@ -89,7 +89,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backend/admin/settings/general/something?test') new HttpUri('http://test.com/backend/admin/settings/general/something?test')
))->getUri()->getRoute() ))->uri->getRoute()
) )
); );
} }
@ -108,7 +108,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backend/admin/settings/general/something?test') new HttpUri('http://test.com/backend/admin/settings/general/something?test')
))->getUri()->getRoute(), null, RouteVerb::PUT) ))->uri->getRoute(), null, RouteVerb::PUT)
); );
} }
@ -125,7 +125,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test') new HttpUri('http://test.com/backends/admin/settings/general/something?test')
))->getUri()->getRoute(), null, RouteVerb::ANY) ))->uri->getRoute(), null, RouteVerb::ANY)
); );
self::assertEquals( self::assertEquals(
@ -133,14 +133,14 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test') new HttpUri('http://test.com/backends/admin/settings/general/something?test')
))->getUri()->getRoute(), null, RouteVerb::SET) ))->uri->getRoute(), null, RouteVerb::SET)
); );
self::assertEquals( self::assertEquals(
[['dest' => 'Controller:test']], [['dest' => 'Controller:test']],
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test')))->getUri()->getRoute(), null, RouteVerb::GET) new HttpUri('http://test.com/backends/admin/settings/general/something?test')))->uri->getRoute(), null, RouteVerb::GET)
); );
} }
@ -158,7 +158,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backend/admin/settings/csrf/something?test') new HttpUri('http://test.com/backend/admin/settings/csrf/something?test')
))->getUri()->getRoute(), ))->uri->getRoute(),
'csrf_string' 'csrf_string'
) )
); );
@ -178,7 +178,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backend/admin/settings/csrf/something?test') new HttpUri('http://test.com/backend/admin/settings/csrf/something?test')
))->getUri()->getRoute() ))->uri->getRoute()
) )
); );
} }
@ -213,7 +213,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
self::assertEquals( self::assertEquals(
[['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']], [['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']],
$this->router->route( $this->router->route(
(new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general/something?test')))->getUri()->getRoute(), (new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general/something?test')))->uri->getRoute(),
null, null,
RouteVerb::GET, RouteVerb::GET,
null, null,
@ -277,7 +277,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
self::assertNotEquals( self::assertNotEquals(
[['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']], [['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']],
$this->router->route( $this->router->route(
(new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general/something?test')))->getUri()->getRoute(), (new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general/something?test')))->uri->getRoute(),
null, null,
RouteVerb::GET, RouteVerb::GET,
null, null,
@ -307,7 +307,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test') new HttpUri('http://test.com/backends/admin/settings/general/something?test')
))->getUri()->getRoute(), null, RouteVerb::ANY, null, null, null, ['test_pattern' => 'abcdef']) ))->uri->getRoute(), null, RouteVerb::ANY, null, null, null, ['test_pattern' => 'abcdef'])
); );
} }
@ -331,7 +331,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test') new HttpUri('http://test.com/backends/admin/settings/general/something?test')
))->getUri()->getRoute(), null, RouteVerb::ANY, null, null, null, ['test_pattern' => '123']) ))->uri->getRoute(), null, RouteVerb::ANY, null, null, null, ['test_pattern' => '123'])
); );
} }
@ -363,7 +363,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backends/admin?something=123&sd=asdf') new HttpUri('http://test.com/backends/admin?something=123&sd=asdf')
))->getUri()->getRoute(), null, RouteVerb::ANY) ))->uri->getRoute(), null, RouteVerb::ANY)
); );
} }
} }

View File

@ -66,9 +66,9 @@ class AddressTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
self::assertEquals('', $this->address->getRecipient()); self::assertEquals('', $this->address->recipient);
self::assertEquals('', $this->address->getFAO()); self::assertEquals('', $this->address->fao);
self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address->getLocation()); self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address->location);
self::assertEquals($expected, $this->address->toArray()); self::assertEquals($expected, $this->address->toArray());
self::assertEquals($expected, $this->address->jsonSerialize()); self::assertEquals($expected, $this->address->jsonSerialize());
} }
@ -80,8 +80,8 @@ class AddressTest extends \PHPUnit\Framework\TestCase
*/ */
public function testFAOInputOutput() : void public function testFAOInputOutput() : void
{ {
$this->address->setFAO('fao'); $this->address->fao = 'fao';
self::assertEquals('fao', $this->address->getFAO()); self::assertEquals('fao', $this->address->fao);
} }
/** /**
@ -91,8 +91,8 @@ class AddressTest extends \PHPUnit\Framework\TestCase
*/ */
public function testRecipientInputOutput() : void public function testRecipientInputOutput() : void
{ {
$this->address->setRecipient('recipient'); $this->address->recipient = 'recipient';
self::assertEquals('recipient', $this->address->getRecipient()); self::assertEquals('recipient', $this->address->recipient);
} }
/** /**
@ -102,9 +102,9 @@ class AddressTest extends \PHPUnit\Framework\TestCase
*/ */
public function testLocationInputOutput() : void public function testLocationInputOutput() : void
{ {
$this->address->setLocation(new Location()); $this->address->location = new Location();
self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address->getLocation()); self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address->location);
} }
/** /**
@ -130,9 +130,9 @@ class AddressTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
$this->address->setFAO('fao'); $this->address->fao = 'fao';
$this->address->setRecipient('recipient'); $this->address->recipient = 'recipient';
$this->address->setLocation(new Location()); $this->address->location = new Location();
self::assertEquals($expected, $this->address->toArray()); self::assertEquals($expected, $this->address->toArray());
} }
@ -160,9 +160,9 @@ class AddressTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
$this->address->setFAO('fao'); $this->address->fao = 'fao';
$this->address->setRecipient('recipient'); $this->address->recipient = 'recipient';
$this->address->setLocation(new Location()); $this->address->location = new Location();
self::assertEquals($expected, $this->address->jsonSerialize()); self::assertEquals($expected, $this->address->jsonSerialize());
} }

View File

@ -65,11 +65,11 @@ class LocationTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
self::assertEquals('', $this->location->getPostal()); self::assertEquals('', $this->location->postal);
self::assertEquals('', $this->location->getCity()); self::assertEquals('', $this->location->city);
self::assertEquals('US', $this->location->getCountry()); self::assertEquals('US', $this->location->getCountry());
self::assertEquals('', $this->location->getAddress()); self::assertEquals('', $this->location->address);
self::assertEquals('', $this->location->getState()); self::assertEquals('', $this->location->state);
self::assertEquals(0, $this->location->getId()); self::assertEquals(0, $this->location->getId());
self::assertEquals(AddressType::HOME, $this->location->getType()); self::assertEquals(AddressType::HOME, $this->location->getType());
self::assertEquals(['lat' => 0, 'long' => 0], $this->location->getGeo()); self::assertEquals(['lat' => 0, 'long' => 0], $this->location->getGeo());
@ -84,8 +84,8 @@ class LocationTest extends \PHPUnit\Framework\TestCase
*/ */
public function testPostalInputOutput() : void public function testPostalInputOutput() : void
{ {
$this->location->setPostal('0123456789'); $this->location->postal = '0123456789';
self::assertEquals('0123456789', $this->location->getPostal()); self::assertEquals('0123456789', $this->location->postal);
} }
/** /**
@ -106,8 +106,8 @@ class LocationTest extends \PHPUnit\Framework\TestCase
*/ */
public function testCityInputOutput() : void public function testCityInputOutput() : void
{ {
$this->location->setCity('city'); $this->location->city = 'city';
self::assertEquals('city', $this->location->getCity()); self::assertEquals('city', $this->location->city);
} }
/** /**
@ -128,8 +128,8 @@ class LocationTest extends \PHPUnit\Framework\TestCase
*/ */
public function testAddressInputOutput() : void public function testAddressInputOutput() : void
{ {
$this->location->setAddress('Some address here'); $this->location->address = 'Some address here';
self::assertEquals('Some address here', $this->location->getAddress()); self::assertEquals('Some address here', $this->location->address);
} }
/** /**
@ -139,8 +139,8 @@ class LocationTest extends \PHPUnit\Framework\TestCase
*/ */
public function testStateInputOutput() : void public function testStateInputOutput() : void
{ {
$this->location->setState('This is a state 123'); $this->location->state = 'This is a state 123';
self::assertEquals('This is a state 123', $this->location->getState()); self::assertEquals('This is a state 123', $this->location->state);
} }
/** /**
@ -173,12 +173,12 @@ class LocationTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
$this->location->setPostal('0123456789'); $this->location->postal = '0123456789';
$this->location->setType(AddressType::BUSINESS); $this->location->setType(AddressType::BUSINESS);
$this->location->setCity('city'); $this->location->city = 'city';
$this->location->address = 'Some address here';
$this->location->state = 'This is a state 123';
$this->location->setCountry('Country'); $this->location->setCountry('Country');
$this->location->setAddress('Some address here');
$this->location->setState('This is a state 123');
$this->location->setGeo(['lat' => 12.1, 'long' => 11.2,]); $this->location->setGeo(['lat' => 12.1, 'long' => 11.2,]);
self::assertEquals($expected, $this->location->toArray()); self::assertEquals($expected, $this->location->toArray());
@ -203,12 +203,12 @@ class LocationTest extends \PHPUnit\Framework\TestCase
], ],
]; ];
$this->location->setPostal('0123456789'); $this->location->postal = '0123456789';
$this->location->setType(AddressType::BUSINESS); $this->location->setType(AddressType::BUSINESS);
$this->location->setCity('city'); $this->location->city = 'city';
$this->location->address = 'Some address here';
$this->location->state = 'This is a state 123';
$this->location->setCountry('Country'); $this->location->setCountry('Country');
$this->location->setAddress('Some address here');
$this->location->setState('This is a state 123');
$this->location->setGeo(['lat' => 12.1, 'long' => 11.2,]); $this->location->setGeo(['lat' => 12.1, 'long' => 11.2,]);
self::assertEquals($expected, $this->location->jsonSerialize()); self::assertEquals($expected, $this->location->jsonSerialize());

View File

@ -852,7 +852,7 @@ class FileTest extends \PHPUnit\Framework\TestCase
$file->createNode(); $file->createNode();
$now = new \DateTime('now'); $now = new \DateTime('now');
self::assertEquals($now->format('Y-m-d'), $file->getCreatedAt()->format('Y-m-d')); self::assertEquals($now->format('Y-m-d'), $file->createdAt->format('Y-m-d'));
\unlink($testFile); \unlink($testFile);
} }

View File

@ -50,11 +50,11 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase
self::assertEquals('/', $obj->getRootPath()); self::assertEquals('/', $obj->getRootPath());
self::assertEquals(0, $obj->getPathOffset()); self::assertEquals(0, $obj->getPathOffset());
self::assertEquals('', $obj->getScheme()); self::assertEquals('', $obj->scheme);
self::assertEquals('', $obj->getHost()); self::assertEquals('', $obj->host);
self::assertEquals(0, $obj->getPort()); self::assertEquals(0, $obj->port);
self::assertEquals('', $obj->getPass()); self::assertEquals('', $obj->pass);
self::assertEquals('', $obj->getUser()); self::assertEquals('', $obj->user);
self::assertEquals('', $obj->getAuthority()); self::assertEquals('', $obj->getAuthority());
self::assertEquals('', $obj->getUserInfo()); self::assertEquals('', $obj->getUserInfo());
self::assertEquals('', $obj->getBase()); self::assertEquals('', $obj->getBase());
@ -97,8 +97,8 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag');
$obj->setScheme('scheme'); $obj->scheme = 'scheme';
self::assertEquals('scheme', $obj->getScheme()); self::assertEquals('scheme', $obj->scheme);
} }
/** /**
@ -109,8 +109,8 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag');
$obj->setUser('user'); $obj->user = 'user';
self::assertEquals('user', $obj->getUser()); self::assertEquals('user', $obj->user);
} }
/** /**
@ -121,8 +121,8 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag');
$obj->setPass('pass'); $obj->pass = 'pass';
self::assertEquals('pass', $obj->getPass()); self::assertEquals('pass', $obj->pass);
} }
/** /**
@ -133,8 +133,8 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag');
$obj->setHost('host'); $obj->host = 'host';
self::assertEquals('host', $obj->getHost()); self::assertEquals('host', $obj->host);
} }
/** /**
@ -145,8 +145,8 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag');
$obj->setPort(123); $obj->port = 123;
self::assertEquals(123, $obj->getPort()); self::assertEquals(123, $obj->port);
} }
/** /**
@ -197,10 +197,10 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag'); $obj = new Argument(':modules/admin/test/path.php ?para1=abc ?para2=2 #frag');
self::assertEquals('frag', $obj->getFragment()); self::assertEquals('frag', $obj->fragment);
$obj->setFragment('frag2'); $obj->fragment = 'frag2';
self::assertEquals('frag2', $obj->getFragment()); self::assertEquals('frag2', $obj->fragment);
} }
/** /**

View File

@ -47,9 +47,9 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new HttpUri('https://www.google.com/test/path.php?para1=abc&para2=2#frag'); $obj = new HttpUri('https://www.google.com/test/path.php?para1=abc&para2=2#frag');
self::assertEquals('', $obj->getPass()); self::assertEquals('', $obj->pass);
self::assertEquals('', $obj->getUser()); self::assertEquals('', $obj->user);
self::assertEquals(80, $obj->getPort()); self::assertEquals(80, $obj->port);
self::assertEquals('', $obj->getUserInfo()); self::assertEquals('', $obj->getUserInfo());
self::assertEquals('', $obj->getRootPath()); self::assertEquals('', $obj->getRootPath());
self::assertEquals(0, $obj->getPathOffset()); self::assertEquals(0, $obj->getPathOffset());
@ -64,10 +64,10 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new HttpUri('https://www.google.com/test/path.php?para1=abc&para2=2#frag'); $obj = new HttpUri('https://www.google.com/test/path.php?para1=abc&para2=2#frag');
self::assertEquals('https', $obj->getScheme()); self::assertEquals('https', $obj->scheme);
$obj->setScheme('ftp'); $obj->scheme = 'ftp';
self::assertEquals('ftp', $obj->getScheme()); self::assertEquals('ftp', $obj->scheme);
} }
/** /**
@ -78,10 +78,10 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new HttpUri('https://www.google.com:21/test/path.php?para1=abc&para2=2#frag'); $obj = new HttpUri('https://www.google.com:21/test/path.php?para1=abc&para2=2#frag');
self::assertEquals(21, $obj->getPort()); self::assertEquals(21, $obj->port);
$obj->setPort(123); $obj->port = 123;
self::assertEquals(123, $obj->getPort()); self::assertEquals(123, $obj->port);
} }
/** /**
@ -93,10 +93,10 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new HttpUri('https://www.google.com/test/path.php?para1=abc&para2=2#frag'); $obj = new HttpUri('https://www.google.com/test/path.php?para1=abc&para2=2#frag');
self::assertEquals('www.google.com', $obj->getHost()); self::assertEquals('www.google.com', $obj->host);
$obj->setHost('127.0.0.1'); $obj->host = '127.0.0.1';
self::assertEquals('127.0.0.1', $obj->getHost()); self::assertEquals('127.0.0.1', $obj->host);
} }
/** /**
@ -108,10 +108,10 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new HttpUri('https://username:password@google.com/test/path.php?para1=abc&para2=2#frag'); $obj = new HttpUri('https://username:password@google.com/test/path.php?para1=abc&para2=2#frag');
self::assertEquals('username', $obj->getUser()); self::assertEquals('username', $obj->user);
$obj->setUser('user'); $obj->user = 'user';
self::assertEquals('user', $obj->getUser()); self::assertEquals('user', $obj->user);
} }
/** /**
@ -123,10 +123,10 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase
{ {
$obj = new HttpUri('https://username:password@google.com/test/path.php?para1=abc&para2=2#frag'); $obj = new HttpUri('https://username:password@google.com/test/path.php?para1=abc&para2=2#frag');
self::assertEquals('password', $obj->getPass()); self::assertEquals('password', $obj->pass);
$obj->setPass('pass'); $obj->pass = 'pass';
self::assertEquals('pass', $obj->getPass()); self::assertEquals('pass', $obj->pass);
} }
/** /**
@ -253,10 +253,10 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase
public function testFragment() : void public function testFragment() : void
{ {
$obj = new HttpUri('https://www.google.com/test/path.php?para1=abc&para2=2#frag'); $obj = new HttpUri('https://www.google.com/test/path.php?para1=abc&para2=2#frag');
self::assertEquals('frag', $obj->getFragment()); self::assertEquals('frag', $obj->fragment);
$obj->setFragment('frag2'); $obj->fragment = 'frag2';
self::assertEquals('frag2', $obj->getFragment()); self::assertEquals('frag2', $obj->fragment);
} }
/** /**
@ -293,9 +293,9 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase
$obj = new HttpUri('http:///03*l.2/test?abc=d'); $obj = new HttpUri('http:///03*l.2/test?abc=d');
self::assertEquals('', $obj->getPath()); self::assertEquals('', $obj->getPath());
self::assertEquals('', $obj->getPass()); self::assertEquals('', $obj->pass);
self::assertEquals('', $obj->getUser()); self::assertEquals('', $obj->user);
self::assertEquals(80, $obj->getPort()); self::assertEquals(80, $obj->port);
self::assertEquals('', $obj->getUserInfo()); self::assertEquals('', $obj->getUserInfo());
self::assertEquals('', $obj->getRootPath()); self::assertEquals('', $obj->getRootPath());
} }

View File

@ -161,7 +161,7 @@ class UriFactoryTest extends \PHPUnit\Framework\TestCase
*/ */
public function testBuilder() : void public function testBuilder() : void
{ {
$uri = 'www.test-uri.com?id={@ID}&test={.mTest}&two={/path}&hash={#hash}&none=#none&found={/not}?v={/valid2}'; $uri = 'www.test-uri.com?id={@ID}&test={.mTest}&two={/path}&hash={#hash}&none=#none&found={/not}&v={/valid2}';
$vars = [ $vars = [
'@ID' => 1, '@ID' => 1,
@ -172,7 +172,7 @@ class UriFactoryTest extends \PHPUnit\Framework\TestCase
self::assertTrue(UriFactory::setQuery('/valid2', 'query4')); self::assertTrue(UriFactory::setQuery('/valid2', 'query4'));
$expected = 'www.test-uri.com?id=1&test=someString&two=PATH&hash=test&none=%23none&found=%2Fnot&v=query4'; $expected = 'www.test-uri.com?id=1&test=someString&two=PATH&hash=test&none=%23none&v=query4';
self::assertEquals($expected, UriFactory::build($uri, $vars)); self::assertEquals($expected, UriFactory::build($uri, $vars));
} }

View File

@ -31,7 +31,7 @@ class AuthorTest extends \PHPUnit\Framework\TestCase
public function testDefault() : void public function testDefault() : void
{ {
$author = new Author(); $author = new Author();
self::assertEquals('', $author->getName()); self::assertEquals('', $author->name);
self::assertEquals('', $author->getEmail()); self::assertEquals('', $author->getEmail());
self::assertEquals(0, $author->getCommitCount()); self::assertEquals(0, $author->getCommitCount());
self::assertEquals(0, $author->getAdditionCount()); self::assertEquals(0, $author->getAdditionCount());
@ -46,7 +46,7 @@ class AuthorTest extends \PHPUnit\Framework\TestCase
public function testConstructInputOutput() : void public function testConstructInputOutput() : void
{ {
$author = new Author('test', 'email'); $author = new Author('test', 'email');
self::assertEquals('test', $author->getName()); self::assertEquals('test', $author->name);
self::assertEquals('email', $author->getEmail()); self::assertEquals('email', $author->getEmail());
} }

View File

@ -31,7 +31,7 @@ class BranchTest extends \PHPUnit\Framework\TestCase
public function testDefault() : void public function testDefault() : void
{ {
$branch = new Branch(); $branch = new Branch();
self::assertEquals('', $branch->getName()); self::assertEquals('', $branch->name);
} }
/** /**
@ -42,6 +42,6 @@ class BranchTest extends \PHPUnit\Framework\TestCase
public function testConstructInputOutput() : void public function testConstructInputOutput() : void
{ {
$branch = new Branch('test'); $branch = new Branch('test');
self::assertEquals('test', $branch->getName()); self::assertEquals('test', $branch->name);
} }
} }

View File

@ -163,7 +163,7 @@ class CommitTest extends \PHPUnit\Framework\TestCase
$commit = new Commit(); $commit = new Commit();
$commit->setAuthor(new Author('Orange')); $commit->setAuthor(new Author('Orange'));
self::assertEquals('Orange', $commit->getAuthor()->getName()); self::assertEquals('Orange', $commit->getAuthor()->name);
} }
/** /**
@ -176,7 +176,7 @@ class CommitTest extends \PHPUnit\Framework\TestCase
$commit = new Commit(); $commit = new Commit();
$commit->setBranch(new Branch('develop')); $commit->setBranch(new Branch('develop'));
self::assertEquals('develop', $commit->getBranch()->getName()); self::assertEquals('develop', $commit->getBranch()->name);
} }
/** /**
@ -189,7 +189,7 @@ class CommitTest extends \PHPUnit\Framework\TestCase
$commit = new Commit(); $commit = new Commit();
$commit->setTag(new Tag('1.0.0')); $commit->setTag(new Tag('1.0.0'));
self::assertEquals('1.0.0', $commit->getTag()->getName()); self::assertEquals('1.0.0', $commit->getTag()->name);
} }
/** /**

View File

@ -263,8 +263,8 @@ class ViewTest extends \PHPUnit\Framework\TestCase
{ {
$view = new View($this->app->l11nManager, $request = new HttpRequest(new HttpUri('')), $response = new HttpResponse()); $view = new View($this->app->l11nManager, $request = new HttpRequest(new HttpUri('')), $response = new HttpResponse());
self::assertEquals($request, $view->getRequest()); self::assertEquals($request, $view->request);
self::assertEquals($response, $view->getResponse()); self::assertEquals($response, $view->response);
} }
/** /**
@ -276,7 +276,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase
{ {
$view = new View($this->app->l11nManager, new HttpRequest(new HttpUri('')), $response = new HttpResponse()); $view = new View($this->app->l11nManager, new HttpRequest(new HttpUri('')), $response = new HttpResponse());
self::assertEquals($response, $view->getResponse()); self::assertEquals($response, $view->response);
} }
/** /**