diff --git a/Account/Account.php b/Account/Account.php index a7a512170..0a54cb238 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -46,7 +46,7 @@ class Account implements \JsonSerializable, ArrayableInterface * @var string * @since 1.0.0 */ - protected string $name1 = ''; + public string $name1 = ''; /** * Names. @@ -54,7 +54,7 @@ class Account implements \JsonSerializable, ArrayableInterface * @var string * @since 1.0.0 */ - protected string $name2 = ''; + public string $name2 = ''; /** * Names. @@ -62,7 +62,7 @@ class Account implements \JsonSerializable, ArrayableInterface * @var string * @since 1.0.0 */ - protected string $name3 = ''; + public string $name3 = ''; /** * Email. @@ -88,7 +88,7 @@ class Account implements \JsonSerializable, ArrayableInterface * @var null|string * @since 1.0.0 */ - protected ?string $login = null; + public ?string $login = null; /** * Last activity. @@ -104,7 +104,7 @@ class Account implements \JsonSerializable, ArrayableInterface * @var \DateTimeImmutable * @since 1.0.0 */ - protected \DateTimeImmutable $createdAt; + public \DateTimeImmutable $createdAt; /** * Groups. @@ -144,7 +144,7 @@ class Account implements \JsonSerializable, ArrayableInterface * @var Localization * @since 1.0.0 */ - protected $localization; + public Localization $l11n; use PermissionHandlingTrait; @@ -159,10 +159,10 @@ class Account implements \JsonSerializable, ArrayableInterface */ public function __construct(int $id = 0) { - $this->createdAt = new \DateTimeImmutable('now'); - $this->lastActive = new \DateTime('now'); - $this->id = $id; - $this->localization = new Localization(); + $this->createdAt = new \DateTimeImmutable('now'); + $this->lastActive = new \DateTime('now'); + $this->id = $id; + $this->l11n = new Localization(); } /** @@ -177,20 +177,6 @@ class Account implements \JsonSerializable, ArrayableInterface 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. * @@ -220,110 +206,6 @@ class Account implements \JsonSerializable, ArrayableInterface $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. * @@ -429,19 +311,7 @@ class Account implements \JsonSerializable, ArrayableInterface */ public function getLastActive() : \DateTimeInterface { - return $this->lastActive ?? $this->getCreatedAt(); - } - - /** - * Get created at. - * - * @return \DateTimeImmutable - * - * @since 1.0.0 - */ - public function getCreatedAt() : \DateTimeImmutable - { - return $this->createdAt; + return $this->lastActive ?? $this->createdAt; } /** @@ -466,20 +336,6 @@ class Account implements \JsonSerializable, ArrayableInterface $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. * diff --git a/Account/Group.php b/Account/Group.php index e51e0e086..c63a0fd74 100644 --- a/Account/Group.php +++ b/Account/Group.php @@ -41,7 +41,7 @@ class Group implements \JsonSerializable, ArrayableInterface * @var string * @since 1.0.0 */ - protected string $name = ''; + public string $name = ''; /** * Group name. @@ -49,7 +49,7 @@ class Group implements \JsonSerializable, ArrayableInterface * @var string * @since 1.0.0 */ - protected string $description = ''; + public string $description = ''; /** * Group members. @@ -89,58 +89,6 @@ class Group implements \JsonSerializable, ArrayableInterface 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. * diff --git a/Algorithm/Clustering/Kmeans.php b/Algorithm/Clustering/Kmeans.php index eb288854b..b4e5dfdc7 100644 --- a/Algorithm/Clustering/Kmeans.php +++ b/Algorithm/Clustering/Kmeans.php @@ -134,11 +134,11 @@ final class Kmeans } 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. - $clusterPoint->setGroup( - $clusterPoint->getGroup() + 1 + $clusterPoint->group = ( + $clusterPoint->group + 1 ); for ($i = 0; $i < $coordinates; ++$i) { @@ -153,9 +153,9 @@ final class Kmeans * 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. * 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) { $min = $this->nearestClusterCenter($point, $clusterCenters)[0]; - if ($min !== $point->getGroup()) { + if ($min !== $point->group) { ++$changed; - $point->setGroup($min); + $point->group = ($min); } } @@ -175,8 +175,8 @@ final class Kmeans } foreach ($clusterCenters as $key => $center) { - $center->setGroup($key); - $center->setName((string) $key); + $center->group = ($key); + $center->name = (string) $key; } $this->clusterCenters = $clusterCenters; @@ -194,7 +194,7 @@ final class Kmeans */ private function nearestClusterCenter(PointInterface $point, array $clusterCenters) : array { - $index = $point->getGroup(); + $index = $point->group; $dist = \PHP_FLOAT_MAX; foreach ($clusterCenters as $key => $cPoint) { @@ -244,7 +244,7 @@ final class Kmeans } foreach ($points as $point) { - $point->setGroup($this->nearestClusterCenter($point, $clusters)[0]); + $point->group = ($this->nearestClusterCenter($point, $clusters)[0]); } return $clusters; diff --git a/Algorithm/Clustering/Point.php b/Algorithm/Clustering/Point.php index dc4989ea7..9b01a2aba 100644 --- a/Algorithm/Clustering/Point.php +++ b/Algorithm/Clustering/Point.php @@ -38,7 +38,7 @@ class Point implements PointInterface * @var int * @since 1.0.0 */ - private int $group = 0; + public int $group = 0; /** * Name of the point @@ -46,7 +46,7 @@ class Point implements PointInterface * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; /** * Constructor. @@ -85,36 +85,4 @@ class Point implements PointInterface { $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; - } } diff --git a/Algorithm/Clustering/PointInterface.php b/Algorithm/Clustering/PointInterface.php index 44b9cc12e..9d7eb1b0c 100644 --- a/Algorithm/Clustering/PointInterface.php +++ b/Algorithm/Clustering/PointInterface.php @@ -56,44 +56,4 @@ interface PointInterface * @since 1.0.0 */ 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; } diff --git a/Algorithm/JobScheduling/Job.php b/Algorithm/JobScheduling/Job.php index f1a75933a..86c0b9f10 100644 --- a/Algorithm/JobScheduling/Job.php +++ b/Algorithm/JobScheduling/Job.php @@ -54,7 +54,7 @@ class Job implements JobInterface * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; /** * Cosntructor. @@ -96,12 +96,4 @@ class Job implements JobInterface { return $this->end; } - - /** - * {@inheritdoc} - */ - public function getName() : string - { - return $this->name; - } } diff --git a/Algorithm/JobScheduling/JobInterface.php b/Algorithm/JobScheduling/JobInterface.php index a6e13d31e..1f7d56a59 100644 --- a/Algorithm/JobScheduling/JobInterface.php +++ b/Algorithm/JobScheduling/JobInterface.php @@ -51,13 +51,4 @@ interface JobInterface * @since 1.0.0 */ public function getEnd() : ?\DateTime; - - /** - * Get the name of the job - * - * @return string - * - * @since 1.0.0 - */ - public function getName() : string; } diff --git a/Algorithm/Knapsack/Item.php b/Algorithm/Knapsack/Item.php index d1ba36525..cafbe2c20 100644 --- a/Algorithm/Knapsack/Item.php +++ b/Algorithm/Knapsack/Item.php @@ -46,7 +46,7 @@ class Item implements ItemInterface * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; /** * Cosntructor. diff --git a/Algorithm/PathFinding/AStar.php b/Algorithm/PathFinding/AStar.php index cc3d1b274..9b2653759 100644 --- a/Algorithm/PathFinding/AStar.php +++ b/Algorithm/PathFinding/AStar.php @@ -84,7 +84,7 @@ final class AStar implements PathFinderInterface $neighbor->setG($ng); $neighbor->setH($neighbor->getG() ?? $neighbor->getWeight() * Heuristic::metric($neighbor->getCoordinates(), $endNode->getCoordinates(), $heuristic)); $neighbor->setF($neighbor->getG() + $neighbor->getH()); - $neighbor->setParent($node); + $neighbor->parent = $node; if (!$neighbor->isOpened()) { $openList->push($neighbor); @@ -100,7 +100,7 @@ final class AStar implements PathFinderInterface while ($node !== null) { $path->addNode($node); - $node = $node->getParent(); + $node = $node->parent; } return $path; diff --git a/Algorithm/PathFinding/Grid.php b/Algorithm/PathFinding/Grid.php index e81db57a2..d60702482 100644 --- a/Algorithm/PathFinding/Grid.php +++ b/Algorithm/PathFinding/Grid.php @@ -130,7 +130,7 @@ class Grid */ 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; } /** diff --git a/Algorithm/PathFinding/JumpPointSearch.php b/Algorithm/PathFinding/JumpPointSearch.php index 239c50e19..2f7f6dcdf 100644 --- a/Algorithm/PathFinding/JumpPointSearch.php +++ b/Algorithm/PathFinding/JumpPointSearch.php @@ -75,7 +75,7 @@ final class JumpPointSearch implements PathFinderInterface while ($node !== null) { $path->addNode($node); - $node = $node->getParent(); + $node = $node->parent; } return $path; @@ -121,7 +121,7 @@ final class JumpPointSearch implements PathFinderInterface $jumpPoint->setG($ng); $jumpPoint->setH($jumpPoint->getH() ?? Heuristic::metric($jumpPoint->getCoordinates(), $endNode->getCoordinates(), $heuristic)); $jumpPoint->setF($jumpPoint->getG() + $jumpPoint->getH()); - $jumpPoint->setParent($node); + $jumpPoint->parent = $node; if (!$jumpPoint->isOpened()) { $openList->push($jumpPoint); @@ -171,15 +171,15 @@ final class JumpPointSearch implements PathFinderInterface */ private static function findNeighborsStraight(JumpPointNode $node, Grid $grid) : array { - if ($node->getParent() === null) { + if ($node->parent === null) { return $grid->getNeighbors($node, MovementType::STRAIGHT); } $x = $node->getX(); $y = $node->getY(); - $px = $node->getParent()->getX(); - $py = $node->getParent()->getY(); + $px = $node->parent->getX(); + $py = $node->parent->getY(); /** @var int $dx */ $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 { - if ($node->getParent() === null) { + if ($node->parent === null) { return $grid->getNeighbors($node, MovementType::DIAGONAL); } $x = $node->getX(); $y = $node->getY(); - $px = $node->getParent()->getX(); - $py = $node->getParent()->getY(); + $px = $node->parent->getX(); + $py = $node->parent->getY(); /** @var int $dx */ $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 { - if ($node->getParent() === null) { + if ($node->parent === null) { return $grid->getNeighbors($node, MovementType::DIAGONAL_ONE_OBSTACLE); } $x = $node->getX(); $y = $node->getY(); - $px = $node->getParent()->getX(); - $py = $node->getParent()->getY(); + $px = $node->parent->getX(); + $py = $node->parent->getY(); /** @var int $dx */ $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 { - if ($node->getParent() === null) { + if ($node->parent === null) { return $grid->getNeighbors($node, MovementType::DIAGONAL_NO_OBSTACLE); } $x = $node->getX(); $y = $node->getY(); - $px = $node->getParent()->getX(); - $py = $node->getParent()->getY(); + $px = $node->parent->getX(); + $py = $node->parent->getY(); /** @var int $dx */ $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 { - if ($node === null || $pNode === null || !$node->isWalkable()) { + if ($node === null || $pNode === null || !$node->isWalkable) { return null; } @@ -557,7 +557,7 @@ final class JumpPointSearch implements PathFinderInterface */ 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; } @@ -617,7 +617,7 @@ final class JumpPointSearch implements PathFinderInterface */ 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; } @@ -681,7 +681,7 @@ final class JumpPointSearch implements PathFinderInterface */ 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; } diff --git a/Algorithm/PathFinding/Node.php b/Algorithm/PathFinding/Node.php index f7b90fa07..77580920b 100644 --- a/Algorithm/PathFinding/Node.php +++ b/Algorithm/PathFinding/Node.php @@ -54,7 +54,7 @@ class Node * @var bool * @since 1.0.0 */ - private bool $isWalkable = true; + public bool $isWalkable = true; /** * Parent node. @@ -62,7 +62,7 @@ class Node * @var null|Node * @since 1.0.0 */ - private ?Node $parent = null; + public ?Node $parent = null; /** * Constructor. @@ -82,18 +82,6 @@ class Node $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 * @@ -130,32 +118,6 @@ class Node 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? * diff --git a/Auth/OAuth2/Provider/ProviderAbstract.php b/Auth/OAuth2/Provider/ProviderAbstract.php index 82f81d4b8..768ec2bdb 100644 --- a/Auth/OAuth2/Provider/ProviderAbstract.php +++ b/Auth/OAuth2/Provider/ProviderAbstract.php @@ -251,7 +251,7 @@ abstract class ProviderAbstract protected function parseResponse(HttpResponse $response) : array { $content = $response->getBody(); - $type = \implode(';', (array) $response->getHeader()->get('Content-Type')); + $type = \implode(';', (array) $response->header->get('Content-Type')); if (\stripos($type, 'urlencoded') !== false) { \parse_str($content, $parsed); diff --git a/DataStorage/Cache/Connection/FileCache.php b/DataStorage/Cache/Connection/FileCache.php index 5f7b3f603..6070462eb 100644 --- a/DataStorage/Cache/Connection/FileCache.php +++ b/DataStorage/Cache/Connection/FileCache.php @@ -411,7 +411,7 @@ final class FileCache extends ConnectionAbstract foreach ($dir as $file) { if ($file instanceof File) { - $created = $file->getCreatedAt()->getTimestamp(); + $created = $file->createdAt->getTimestamp(); if (($expire >= 0 && $created + $expire < $now) || ($expire < 0 && $created + $this->getExpire($file->getContent()) < $now) ) { diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index dc8057ce8..7082d4459 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -768,13 +768,13 @@ class DataMapperAbstract implements DataMapperInterface $relReflectionClass = new \ReflectionClass($values); $relProperty = $relReflectionClass->getProperty($mapper::$columns[static::$hasMany[$propertyName]['self']]['internal']); - if (!$isPublic) { + if (!($isPublicRel = $relProperty->isPublic())) { $relProperty->setAccessible(true); } $relProperty->setValue($values, $objId); - if (!$isPublic) { + if (!$isPublicRel) { $relProperty->setAccessible(false); } diff --git a/DataStorage/Database/Query/Parameter.php b/DataStorage/Database/Query/Parameter.php index 7a460ee55..add669f28 100644 --- a/DataStorage/Database/Query/Parameter.php +++ b/DataStorage/Database/Query/Parameter.php @@ -30,7 +30,7 @@ class Parameter * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; /** * Constructor. diff --git a/Event/EventManager.php b/Event/EventManager.php index 9d094dbbb..81ecc4c14 100644 --- a/Event/EventManager.php +++ b/Event/EventManager.php @@ -162,23 +162,31 @@ final class EventManager implements \Countable $groups = []; foreach ($this->groups as $groupName => $value) { + $groupNameIsRegex = \stripos($groupName, '/') === 0; + if ($groupIsRegex) { if (\preg_match($group, $groupName) === 1) { $groups[$groupName] = []; } - } elseif (\preg_match($groupName, $group) === 1) { + } elseif ($groupNameIsRegex && \preg_match($groupName, $group) === 1) { + $groups[$groupName] = []; + } elseif ($groupName === $group) { $groups[$groupName] = []; } } foreach ($groups as $groupName => $groupValues) { foreach ($this->groups[$groupName] as $idName => $value) { + $idNameIsRegex = \stripos($idName, '/') === 0; + if ($idIsRegex) { if (\preg_match($id, $idName) === 1) { $groups[$groupName][] = $idName; } - } elseif ($idName !== '' && \preg_match($idName, $id) === 1) { + } elseif ($idNameIsRegex && \preg_match($idName, $id) === 1) { $groups[$groupName][] = $id; + } elseif ($idName === $id) { + $groups[$groupName] = []; } } @@ -218,25 +226,25 @@ final class EventManager implements \Countable $this->groups[$group][$id] = true; } - if (!$this->hasOutstanding($group)) { - 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; + if ($this->hasOutstanding($group)) { + return false; } - 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] = []; } + if (isset($this->groups[$group][''])) { + unset($this->groups[$group]['']); + } + $this->groups[$group][$id] = false; } diff --git a/Localization/Localization.php b/Localization/Localization.php index 4a5f18b04..e7a78b09b 100644 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -50,7 +50,7 @@ class Localization implements \JsonSerializable * @var string * @since 1.0.0 */ - protected string $lang = ISO639x1Enum::_EN; + protected string $language = ISO639x1Enum::_EN; /** * Currency. @@ -381,7 +381,7 @@ class Localization implements \JsonSerializable */ public function getLanguage() : string { - return $this->lang; + return $this->language; } /** @@ -403,7 +403,7 @@ class Localization implements \JsonSerializable throw new InvalidEnumValue($language); } - $this->lang = $language; + $this->language = $language; } /** @@ -769,7 +769,7 @@ class Localization implements \JsonSerializable 'id' => $this->id, 'country' => $this->country, 'timezone' => $this->timezone, - 'language' => $this->lang, + 'language' => $this->language, 'currency' => $this->currency, 'currencyformat' => $this->currencyFormat, 'decimal' => $this->decimal, diff --git a/Message/Console/ConsoleRequest.php b/Message/Console/ConsoleRequest.php index 1d9980a19..34de81f0f 100644 --- a/Message/Console/ConsoleRequest.php +++ b/Message/Console/ConsoleRequest.php @@ -37,7 +37,7 @@ final class ConsoleRequest extends RequestAbstract * @var UriInterface * @since 1.0.0 */ - protected UriInterface $uri; + public UriInterface $uri; /** * Request method. @@ -66,7 +66,7 @@ final class ConsoleRequest extends RequestAbstract public function __construct(UriInterface $uri = null, Localization $l11n = null) { $this->header = new ConsoleHeader(); - $this->header->setL11n($l11n ?? new Localization()); + $this->header->l11n = $l11n ?? new Localization(); $this->uri = $uri ?? new Argument(); $this->init(); @@ -83,7 +83,7 @@ final class ConsoleRequest extends RequestAbstract */ private function init() : void { - $this->header->getL11n()->setLanguage('en'); + $this->header->l11n->setLanguage('en'); } /** diff --git a/Message/Console/ConsoleResponse.php b/Message/Console/ConsoleResponse.php index 9ec9cc0ae..775e3e89c 100644 --- a/Message/Console/ConsoleResponse.php +++ b/Message/Console/ConsoleResponse.php @@ -50,7 +50,7 @@ final class ConsoleResponse extends ResponseAbstract implements RenderableInterf public function __construct(Localization $l11n = null) { $this->header = new ConsoleHeader(); - $this->header->setL11n($l11n ?? new Localization()); + $this->header->l11n = $l11n ?? new Localization(); } /** diff --git a/Message/HeaderAbstract.php b/Message/HeaderAbstract.php index 551ccbcb5..d7df1a80e 100644 --- a/Message/HeaderAbstract.php +++ b/Message/HeaderAbstract.php @@ -40,7 +40,7 @@ abstract class HeaderAbstract * @var Localization * @since 1.0.0 */ - protected Localization $l11n; + public Localization $l11n; /** * Account. @@ -48,7 +48,7 @@ abstract class HeaderAbstract * @var int * @since 1.0.0 */ - protected int $account = 0; + public int $account = 0; /** * Response status. @@ -56,7 +56,7 @@ abstract class HeaderAbstract * @var int * @since 1.0.0 */ - protected int $status = 0; + public int $status = 0; /** * Constructor. @@ -92,72 +92,6 @@ abstract class HeaderAbstract 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. * @@ -169,18 +103,6 @@ abstract class HeaderAbstract */ 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. * diff --git a/Message/Http/HttpHeader.php b/Message/Http/HttpHeader.php index 98131bcd4..e1dee2069 100644 --- a/Message/Http/HttpHeader.php +++ b/Message/Http/HttpHeader.php @@ -45,6 +45,14 @@ final class HttpHeader extends HeaderAbstract */ private static $serverHeaders = []; + /** + * Response status. + * + * @var int + * @since 1.0.0 + */ + public int $status = RequestStatusCode::R_200; + /** * {@inheritdoc} */ @@ -121,22 +129,6 @@ final class HttpHeader extends HeaderAbstract 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 * diff --git a/Message/Http/HttpRequest.php b/Message/Http/HttpRequest.php index c2e1aeb1e..566b31ced 100644 --- a/Message/Http/HttpRequest.php +++ b/Message/Http/HttpRequest.php @@ -75,7 +75,7 @@ final class HttpRequest extends RequestAbstract public function __construct(UriInterface $uri = null, Localization $l11n = null) { $this->header = new HttpHeader(); - $this->header->setL11n($l11n ?? new Localization()); + $this->header->l11n = $l11n ?? new Localization(); if ($uri !== null) { $this->uri = $uri; @@ -116,7 +116,7 @@ final class HttpRequest extends RequestAbstract $this->uri = HttpUri::fromCurrent(); $this->data = ($_GET ?? []) + ($_POST ?? []); $this->files = $_FILES ?? []; - $this->header->getL11n()->setLanguage($this->getRequestLanguage()); + $this->header->l11n->setLanguage($this->getRequestLanguage()); $this->initNonGetData(); } diff --git a/Message/Http/HttpResponse.php b/Message/Http/HttpResponse.php index 4188f5c67..fd57cb0d6 100644 --- a/Message/Http/HttpResponse.php +++ b/Message/Http/HttpResponse.php @@ -42,7 +42,7 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface public function __construct(Localization $l11n = null) { $this->header = new HttpHeader(); - $this->header->setL11n($l11n ?? new Localization()); + $this->header->l11n = $l11n ?? new Localization(); } /** diff --git a/Message/Http/Rest.php b/Message/Http/Rest.php index 6e4747849..d95bf153e 100644 --- a/Message/Http/Rest.php +++ b/Message/Http/Rest.php @@ -48,7 +48,7 @@ final class Rest \curl_setopt($curl, \CURLOPT_NOBODY, true); // handle header - $requestHeaders = $request->getHeader()->get(); + $requestHeaders = $request->header->get(); $headers = []; foreach ($requestHeaders as $key => $header) { @@ -108,9 +108,9 @@ final class Rest } // handle user auth - if ($request->getUri()->getUser() !== '') { + if ($request->uri->user !== '') { \curl_setopt($curl, \CURLOPT_HTTPAUTH, \CURLAUTH_BASIC); - \curl_setopt($curl, \CURLOPT_USERPWD, $request->getUri()->getUserInfo()); + \curl_setopt($curl, \CURLOPT_USERPWD, $request->uri->getUserInfo()); } $cHeaderString = ''; @@ -128,7 +128,7 @@ final class Rest } $name = \strtolower(\trim($header[0])); - $response->getHeader()->set($name, \trim($header[1])); + $response->header->set($name, \trim($header[1])); return $length; } diff --git a/Message/MessageInterface.php b/Message/MessageInterface.php index beca14dc8..19413a440 100644 --- a/Message/MessageInterface.php +++ b/Message/MessageInterface.php @@ -24,15 +24,6 @@ namespace phpOMS\Message; */ interface MessageInterface { - /** - * Retrieves all message header values. - * - * @return null|HeaderAbstract - * - * @since 1.0.0 - */ - public function getHeader() : ?HeaderAbstract; - /** * Gets the body of the message. * diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index 7ff01dd47..9f363209a 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -32,7 +32,7 @@ abstract class RequestAbstract implements MessageInterface * @var UriInterface * @since 1.0.0 */ - protected UriInterface $uri; + public UriInterface $uri; /** * Request data. @@ -64,7 +64,7 @@ abstract class RequestAbstract implements MessageInterface * @var HeaderAbstract * @since 1.0.0 */ - protected HeaderAbstract $header; + public HeaderAbstract $header; /** * Request hash. @@ -219,18 +219,6 @@ abstract class RequestAbstract implements MessageInterface $this->lock = true; } - /** - * Get request header. - * - * @return HeaderAbstract - * - * @since 1.0.0 - */ - public function getHeader() : HeaderAbstract - { - return $this->header; - } - /** * Get request language. * @@ -240,7 +228,7 @@ abstract class RequestAbstract implements MessageInterface */ 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; } - - /** - * Get request uri. - * - * @return UriInterface - * - * @since 1.0.0 - */ - public function getUri() : UriInterface - { - return $this->uri; - } } diff --git a/Message/ResponseAbstract.php b/Message/ResponseAbstract.php index 16511cb38..4ffba77a3 100644 --- a/Message/ResponseAbstract.php +++ b/Message/ResponseAbstract.php @@ -38,7 +38,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface * @var HeaderAbstract * @since 1.0.0 */ - protected HeaderAbstract $header; + public HeaderAbstract $header; /** * Get response by ID. @@ -91,18 +91,6 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface */ abstract public function toArray() : array; - /** - * Get header. - * - * @return HeaderAbstract - * - * @since 1.0.0 - */ - public function getHeader() : HeaderAbstract - { - return $this->header; - } - /** * Get response language. * @@ -112,7 +100,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface */ public function getLanguage() : string { - return $this->header->getL11n()->getLanguage(); + return $this->header->l11n->getLanguage(); } /** diff --git a/Message/Socket/PacketManager.php b/Message/Socket/PacketManager.php index d66f36380..2057a57ad 100644 --- a/Message/Socket/PacketManager.php +++ b/Message/Socket/PacketManager.php @@ -71,7 +71,7 @@ class PacketManager public function handle(string $data, $client) : void { $request = new SocketRequest(); - $request->getHeader()->setAccount($client->getAccount()->getId()); + $request->header->account = $client->getAccount()->getId(); $response = new SocketResponse(); diff --git a/Model/Html/Head.php b/Model/Html/Head.php index 77ff46fc9..97a36dd16 100644 --- a/Model/Html/Head.php +++ b/Model/Html/Head.php @@ -44,7 +44,7 @@ final class Head implements RenderableInterface * @var string * @since 1.0.0 */ - private string $title = ''; + public string $title = ''; /** * Assets bound to this page instance. @@ -68,7 +68,7 @@ final class Head implements RenderableInterface * @var Meta * @since 1.0.0 */ - private Meta $meta; + public Meta $meta; /** * html style. @@ -98,44 +98,6 @@ final class Head implements RenderableInterface $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. * diff --git a/Model/Html/Meta.php b/Model/Html/Meta.php index d98d492fd..b9ff9901e 100644 --- a/Model/Html/Meta.php +++ b/Model/Html/Meta.php @@ -41,7 +41,7 @@ final class Meta implements RenderableInterface * @var string * @since 1.0.0 */ - private string $author = ''; + public string $author = ''; /** * Charset. @@ -57,7 +57,7 @@ final class Meta implements RenderableInterface * @var string * @since 1.0.0 */ - private string $description = ''; + public string $description = ''; /** * Itemprop. @@ -111,32 +111,6 @@ final class Meta implements RenderableInterface 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. * @@ -163,32 +137,6 @@ final class Meta implements RenderableInterface $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. * diff --git a/Module/ModuleAbstract.php b/Module/ModuleAbstract.php index f5a30d335..56049514c 100644 --- a/Module/ModuleAbstract.php +++ b/Module/ModuleAbstract.php @@ -221,8 +221,8 @@ abstract class ModuleAbstract $obj ) : void { - $response->getHeader()->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->getUri()->__toString(), [ + $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); + $response->set($request->uri->__toString(), [ 'status' => $status, 'title' => $title, 'message' => $message, @@ -243,8 +243,8 @@ abstract class ModuleAbstract */ protected function fillJsonRawResponse(RequestAbstract $request, ResponseAbstract $response, $obj) : void { - $response->getHeader()->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); - $response->set($request->getUri()->__toString(), $obj); + $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); + $response->set($request->uri->__toString(), $obj); } /** diff --git a/Socket/Server/Server.php b/Socket/Server/Server.php index 9cf3da819..8b0bb92e3 100644 --- a/Socket/Server/Server.php +++ b/Socket/Server/Server.php @@ -253,7 +253,7 @@ class Server extends SocketAbstract public function shutdown($request) : void { $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; } diff --git a/Stdlib/Base/Address.php b/Stdlib/Base/Address.php index 2875197f6..1da274687 100644 --- a/Stdlib/Base/Address.php +++ b/Stdlib/Base/Address.php @@ -30,7 +30,7 @@ class Address implements \JsonSerializable * @var string * @since 1.0.0 */ - private string $recipient = ''; + public string $recipient = ''; /** * Sub of the address. @@ -38,7 +38,7 @@ class Address implements \JsonSerializable * @var string * @since 1.0.0 */ - private string $fao = ''; + public string $fao = ''; /** * Location. @@ -46,7 +46,7 @@ class Address implements \JsonSerializable * @var Location * @since 1.0.0 */ - private Location $location; + public Location $location; /** * Constructor. @@ -58,84 +58,6 @@ class Address implements \JsonSerializable $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} */ diff --git a/Stdlib/Base/Location.php b/Stdlib/Base/Location.php index a5ebe0f4b..74b1b761d 100644 --- a/Stdlib/Base/Location.php +++ b/Stdlib/Base/Location.php @@ -40,7 +40,7 @@ class Location implements \JsonSerializable, \Serializable * @var string * @since 1.0.0 */ - protected string $postal = ''; + public string $postal = ''; /** * Name of city. @@ -48,7 +48,7 @@ class Location implements \JsonSerializable, \Serializable * @var string * @since 1.0.0 */ - protected string $city = ''; + public string $city = ''; /** * Name of the country. @@ -64,7 +64,7 @@ class Location implements \JsonSerializable, \Serializable * @var string * @since 1.0.0 */ - protected string $address = ''; + public string $address = ''; /** * Address type @@ -80,7 +80,7 @@ class Location implements \JsonSerializable, \Serializable * @var string * @since 1.0.0 */ - protected string $state = ''; + public string $state = ''; /** * Geo coordinates. @@ -128,58 +128,6 @@ class Location implements \JsonSerializable, \Serializable $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 * @@ -206,58 +154,6 @@ class Location implements \JsonSerializable, \Serializable $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 * diff --git a/System/File/Ftp/Directory.php b/System/File/Ftp/Directory.php index 6e9e34537..75890971b 100644 --- a/System/File/Ftp/Directory.php +++ b/System/File/Ftp/Directory.php @@ -61,13 +61,13 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer */ 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) { return false; } - \ftp_login($con, $http->getUser(), $http->getPass()); + \ftp_login($con, $http->user, $http->pass); if ($http->getPath() !== '') { @\ftp_chdir($con, $http->getPath()); @@ -620,7 +620,7 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer /** * {@inheritdoc} */ - public function getParent() : ContainerInterface + public function getParent(): ContainerInterface { $uri = clone $this->uri; $uri->setPath(self::parent($this->path)); diff --git a/System/File/Ftp/File.php b/System/File/Ftp/File.php index e9f8d1340..6bc22fa30 100644 --- a/System/File/Ftp/File.php +++ b/System/File/Ftp/File.php @@ -77,13 +77,13 @@ class File extends FileAbstract implements FileInterface */ 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) { return false; } - \ftp_login($con, $http->getUser(), $http->getPass()); + \ftp_login($con, $http->user, $http->pass); if ($http->getPath() !== '') { @\ftp_chdir($con, $http->getPath()); diff --git a/System/File/Local/FileAbstract.php b/System/File/Local/FileAbstract.php index 7bdf7b65a..5fe8c95c5 100644 --- a/System/File/Local/FileAbstract.php +++ b/System/File/Local/FileAbstract.php @@ -66,7 +66,7 @@ abstract class FileAbstract implements ContainerInterface * @var \DateTimeImmutable * @since 1.0.0 */ - protected \DateTimeImmutable $createdAt; + public \DateTimeImmutable $createdAt; /** * Last changed at. diff --git a/Uri/Argument.php b/Uri/Argument.php index 0c4aef228..18cf1e062 100644 --- a/Uri/Argument.php +++ b/Uri/Argument.php @@ -68,7 +68,7 @@ final class Argument implements UriInterface * @var string * @since 1.0.0 */ - private string $scheme = ''; + public string $scheme = ''; /** * Uri host. @@ -76,7 +76,7 @@ final class Argument implements UriInterface * @var string * @since 1.0.0 */ - private string $host = ''; + public string $host = ''; /** * Uri port. @@ -84,7 +84,7 @@ final class Argument implements UriInterface * @var int * @since 1.0.0 */ - private int $port = 0; + public int $port = 0; /** * Uri user. @@ -92,7 +92,7 @@ final class Argument implements UriInterface * @var string * @since 1.0.0 */ - private string $user = ''; + public string $user = ''; /** * Uri password. @@ -100,7 +100,7 @@ final class Argument implements UriInterface * @var string * @since 1.0.0 */ - private string $pass = ''; + public string $pass = ''; /** * Uri path. @@ -132,7 +132,7 @@ final class Argument implements UriInterface * @var string * @since 1.0.0 */ - private string $fragment = ''; + public string $fragment = ''; /** * Uri base. @@ -280,70 +280,6 @@ final class Argument implements UriInterface $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} */ @@ -420,22 +356,6 @@ final class Argument implements UriInterface return $this->query; } - /** - * {@inheritdoc} - */ - public function getFragment() : string - { - return $this->fragment; - } - - /** - * {@inheritdoc} - */ - public function setFragment(string $fragment) : void - { - $this->fragment = $fragment; - } - /** * {@inheritdoc} */ @@ -460,22 +380,6 @@ final class Argument implements UriInterface return ''; } - /** - * {@inheritdoc} - */ - public function getUser() : string - { - return $this->user; - } - - /** - * {@inheritdoc} - */ - public function setUser(string $user) : void - { - $this->user = $user; - } - /** * {@inheritdoc} */ diff --git a/Uri/HttpUri.php b/Uri/HttpUri.php index d0e339ffe..489202aba 100644 --- a/Uri/HttpUri.php +++ b/Uri/HttpUri.php @@ -68,7 +68,7 @@ final class HttpUri implements UriInterface * @var string * @since 1.0.0 */ - private string $scheme; + public string $scheme; /** * Uri host. @@ -76,7 +76,7 @@ final class HttpUri implements UriInterface * @var string * @since 1.0.0 */ - private string $host; + public string $host; /** * Uri port. @@ -84,7 +84,7 @@ final class HttpUri implements UriInterface * @var int * @since 1.0.0 */ - private int $port; + public int $port; /** * Uri user. @@ -92,7 +92,7 @@ final class HttpUri implements UriInterface * @var string * @since 1.0.0 */ - private string $user; + public string $user; /** * Uri password. @@ -100,7 +100,7 @@ final class HttpUri implements UriInterface * @var string * @since 1.0.0 */ - private string $pass; + public string $pass; /** * Uri path. @@ -132,7 +132,7 @@ final class HttpUri implements UriInterface * @var string * @since 1.0.0 */ - private string $fragment; + public string $fragment; /** * Uri base. @@ -271,38 +271,6 @@ final class HttpUri implements UriInterface $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 * @@ -322,38 +290,6 @@ final class HttpUri implements UriInterface 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} */ @@ -430,22 +366,6 @@ final class HttpUri implements UriInterface return $this->query; } - /** - * {@inheritdoc} - */ - public function getFragment() : string - { - return $this->fragment; - } - - /** - * {@inheritdoc} - */ - public function setFragment(string $fragment) : void - { - $this->fragment = $fragment; - } - /** * {@inheritdoc} */ @@ -467,24 +387,8 @@ final class HttpUri implements UriInterface */ public function getAuthority() : string { - return ($this->getUser() !== '' ? $this->getUser() . '@' : '') . $this->host - . ($this->port !== null && $this->port !== 0 ? ':' . $this->port : ''); - } - - /** - * {@inheritdoc} - */ - public function getUser() : string - { - return $this->user; - } - - /** - * {@inheritdoc} - */ - public function setUser(string $user) : void - { - $this->user = $user; + return ($this->user !== '' ? $this->user . '@' : '') . $this->host + . ($this->port !== 0 ? ':' . $this->port : ''); } /** diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index d2446a06d..bf29f1848 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -113,17 +113,17 @@ final class UriFactory */ public static function setupUriBuilder(UriInterface $uri) : void { - self::setQuery('/scheme', $uri->getScheme()); - self::setQuery('/host', $uri->getHost()); - self::setQuery('/port', (string) $uri->getPort()); + self::setQuery('/scheme', $uri->scheme); + self::setQuery('/host', $uri->host); + self::setQuery('/port', (string) $uri->port); self::setQuery('/base', \rtrim($uri->getBase(), '/')); self::setQuery('/rootPath', $uri->getRootPath()); self::setQuery('?', '?' . $uri->getQuery()); self::setQuery('%', $uri->__toString()); - self::setQuery('#', $uri->getFragment()); + self::setQuery('#', $uri->fragment); self::setQuery('/', $uri->getPath()); - self::setQuery(':user', $uri->getUser()); - self::setQuery(':pass', $uri->getPass()); + self::setQuery(':user', $uri->user); + self::setQuery(':pass', $uri->pass); $data = $uri->getPathElements(); foreach ($data as $key => $value) { diff --git a/Uri/UriInterface.php b/Uri/UriInterface.php index 2b5fef13b..a4731bfaf 100644 --- a/Uri/UriInterface.php +++ b/Uri/UriInterface.php @@ -35,26 +35,6 @@ interface UriInterface */ 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. * @@ -73,46 +53,6 @@ interface UriInterface */ 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. * @@ -133,46 +73,6 @@ interface UriInterface */ 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. * @@ -246,26 +146,6 @@ interface UriInterface */ 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. * diff --git a/Utils/Git/Author.php b/Utils/Git/Author.php index 2ceefabd6..1ac53b9cd 100644 --- a/Utils/Git/Author.php +++ b/Utils/Git/Author.php @@ -30,7 +30,7 @@ class Author * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; /** * Email. @@ -78,18 +78,6 @@ class Author $this->email = $email; } - /** - * Get name - * - * @return string - * - * @since 1.0.0 - */ - public function getName() : string - { - return $this->name; - } - /** * Get email * diff --git a/Utils/Git/Branch.php b/Utils/Git/Branch.php index 1c2ce0959..05ee612bf 100644 --- a/Utils/Git/Branch.php +++ b/Utils/Git/Branch.php @@ -30,7 +30,7 @@ class Branch * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; /** * Constructor @@ -44,18 +44,6 @@ class Branch $this->setName($name); } - /** - * Get name - * - * @return string - * - * @since 1.0.0 - */ - public function getName() : string - { - return $this->name; - } - /** * Set branch name * diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 0082bbc34..d4f98ef30 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -42,7 +42,7 @@ class Repository * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; /** * Bare repository. diff --git a/Utils/Git/Tag.php b/Utils/Git/Tag.php index 911e55696..070c50409 100644 --- a/Utils/Git/Tag.php +++ b/Utils/Git/Tag.php @@ -30,7 +30,7 @@ class Tag * @var string * @since 1.0.0 */ - private string $name = ''; + public string $name = ''; /** * Message. diff --git a/Views/View.php b/Views/View.php index 2f572aaa3..d78f31009 100644 --- a/Views/View.php +++ b/Views/View.php @@ -61,7 +61,7 @@ class View extends ViewAbstract * @var null|RequestAbstract * @since 1.0.0 */ - protected ?RequestAbstract $request; + public ?RequestAbstract $request; /** * Request. @@ -69,7 +69,7 @@ class View extends ViewAbstract * @var null|ResponseAbstract * @since 1.0.0 */ - protected ?ResponseAbstract $response; + public ?ResponseAbstract $response; /** * Theme name. @@ -101,7 +101,7 @@ class View extends ViewAbstract $this->l11nManager = $l11n ?? new L11nManager('Error'); $this->request = $request; $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); } - - /** - * 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; - } } diff --git a/tests/Account/AccountTest.php b/tests/Account/AccountTest.php index d855049ac..ec6e3d034 100644 --- a/tests/Account/AccountTest.php +++ b/tests/Account/AccountTest.php @@ -63,7 +63,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase self::assertObjectHasAttribute('groups', $account); self::assertObjectHasAttribute('type', $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::assertEquals(0, $account->getId()); - self::assertInstanceOf('\phpOMS\Localization\Localization', $account->getL11n()); + self::assertInstanceOf('\phpOMS\Localization\Localization', $account->l11n); self::assertEquals([], $account->getGroups()); - self::assertNull($account->getName()); + self::assertNull($account->login); - self::assertIsString($account->getName1()); - self::assertEquals('', $account->getName1()); + self::assertIsString($account->name1); + self::assertEquals('', $account->name1); - self::assertIsString($account->getName2()); - self::assertEquals('', $account->getName2()); + self::assertIsString($account->name2); + self::assertEquals('', $account->name2); - self::assertIsString($account->getName3()); - self::assertEquals('', $account->getName3()); + self::assertIsString($account->name3); + self::assertEquals('', $account->name3); self::assertIsString($account->getEmail()); self::assertEquals('', $account->getEmail()); @@ -106,7 +106,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase self::assertEquals([], $account->getPermissions()); self::assertInstanceOf('\DateTimeInterface', $account->getLastActive()); - self::assertInstanceOf('\DateTimeImmutable', $account->getCreatedAt()); + self::assertInstanceOf('\DateTimeImmutable', $account->createdAt); $array = $account->toArray(); self::assertIsArray($array); @@ -125,20 +125,17 @@ class AccountTest extends \PHPUnit\Framework\TestCase $account = new Account(); $account->generatePassword('abcd'); - $account->setName('Login'); - self::assertEquals('Login', $account->getName()); + $account->login = 'Login'; + self::assertEquals('Login', $account->login); - $account->setName1('Donald'); - self::assertEquals('Donald', $account->getName1()); + $account->name1 = 'Donald'; + self::assertEquals('Donald', $account->name1); - $account->setName2('Fauntleroy'); - self::assertEquals('Fauntleroy', $account->getName2()); + $account->name2 = 'Fauntleroy'; + self::assertEquals('Fauntleroy', $account->name2); - $account->setName3('Duck'); - self::assertEquals('Duck', $account->getName3()); - - $account->setName('Login'); - self::assertEquals('Login', $account->getName()); + $account->name3 = 'Duck'; + self::assertEquals('Duck', $account->name3); } /** @@ -276,8 +273,8 @@ class AccountTest extends \PHPUnit\Framework\TestCase $account = new Account(); $account->generatePassword('abcd'); - $account->setL11n(new Localization()); - self::assertInstanceOf('\phpOMS\Localization\Localization', $account->getL11n()); + $account->l11n = new Localization(); + self::assertInstanceOf('\phpOMS\Localization\Localization', $account->l11n); } /** diff --git a/tests/Account/GroupTest.php b/tests/Account/GroupTest.php index f2a5c4607..474a0c625 100644 --- a/tests/Account/GroupTest.php +++ b/tests/Account/GroupTest.php @@ -61,14 +61,14 @@ class GroupTest extends \PHPUnit\Framework\TestCase self::assertIsInt($group->getId()); self::assertEquals(0, $group->getId()); - self::assertIsString($group->getName()); - self::assertEquals('', $group->getName()); + self::assertIsString($group->name); + self::assertEquals('', $group->name); self::assertIsInt($group->getStatus()); self::assertEquals(GroupStatus::INACTIVE, $group->getStatus()); - self::assertIsString($group->getDescription()); - self::assertEquals('', $group->getDescription()); + self::assertIsString($group->description); + self::assertEquals('', $group->description); $array = $group->toArray(); self::assertIsArray($array); @@ -86,11 +86,11 @@ class GroupTest extends \PHPUnit\Framework\TestCase { $group = new Group(); - $group->setName('Duck'); - self::assertEquals('Duck', $group->getName()); + $group->name = 'Duck'; + self::assertEquals('Duck', $group->name); - $group->setDescription('Animal'); - self::assertEquals('Animal', $group->getDescription()); + $group->description = 'Animal'; + self::assertEquals('Animal', $group->description); } /** diff --git a/tests/Algorithm/Clustering/KmeansTest.php b/tests/Algorithm/Clustering/KmeansTest.php index 877b52835..ce93a0197 100644 --- a/tests/Algorithm/Clustering/KmeansTest.php +++ b/tests/Algorithm/Clustering/KmeansTest.php @@ -47,13 +47,13 @@ class KmeansTest extends \PHPUnit\Framework\TestCase $kmeans = new Kmeans($points, 2); - if ($kmeans->cluster($points[0])->getGroup() === 0 - && $kmeans->cluster($points[1])->getGroup() === 0 - && $kmeans->cluster($points[2])->getGroup() === 1 - && $kmeans->cluster($points[3])->getGroup() === 1 - && $kmeans->cluster($points[4])->getGroup() === 1 - && $kmeans->cluster($points[5])->getGroup() === 1 - && $kmeans->cluster($points[6])->getGroup() === 1 + if ($kmeans->cluster($points[0])->group === 0 + && $kmeans->cluster($points[1])->group === 0 + && $kmeans->cluster($points[2])->group === 1 + && $kmeans->cluster($points[3])->group === 1 + && $kmeans->cluster($points[4])->group === 1 + && $kmeans->cluster($points[5])->group === 1 + && $kmeans->cluster($points[6])->group === 1 ) { $result = true; diff --git a/tests/Algorithm/Clustering/PointTest.php b/tests/Algorithm/Clustering/PointTest.php index b00addeb3..bee53433b 100644 --- a/tests/Algorithm/Clustering/PointTest.php +++ b/tests/Algorithm/Clustering/PointTest.php @@ -35,8 +35,8 @@ class PointTest extends \PHPUnit\Framework\TestCase self::assertEquals([3.0, 2.0], $point->getCoordinates()); self::assertEquals(3.0, $point->getCoordinate(0)); self::assertEquals(2.0, $point->getCoordinate(1)); - self::assertEquals(0, $point->getGroup()); - self::assertEquals('abc', $point->getName()); + self::assertEquals(0, $point->group); + self::assertEquals('abc', $point->name); } /** @@ -65,8 +65,8 @@ class PointTest extends \PHPUnit\Framework\TestCase { $point = new Point([3.0, 2.0], 'abc'); - $point->setGroup(2); - self::assertEquals(2, $point->getGroup()); + $point->group = 2; + self::assertEquals(2, $point->group); } /** @@ -78,7 +78,7 @@ class PointTest extends \PHPUnit\Framework\TestCase { $point = new Point([3.0, 2.0], 'abc'); - $point->setName('xyz'); - self::assertEquals('xyz', $point->getName()); + $point->name = 'xyz'; + self::assertEquals('xyz', $point->name); } } diff --git a/tests/Algorithm/JobScheduling/JobTest.php b/tests/Algorithm/JobScheduling/JobTest.php index 834437cd1..c207c053d 100644 --- a/tests/Algorithm/JobScheduling/JobTest.php +++ b/tests/Algorithm/JobScheduling/JobTest.php @@ -35,6 +35,6 @@ class JobTest extends \PHPUnit\Framework\TestCase self::assertEquals(3.0, $item->getValue()); self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $item->getStart()->format('Y-m-d')); self::assertNull($item->getEnd()); - self::assertEquals('abc', $item->getName()); + self::assertEquals('abc', $item->name); } } diff --git a/tests/Algorithm/JobScheduling/WeightedTest.php b/tests/Algorithm/JobScheduling/WeightedTest.php index ff7e15ad6..a218b18e9 100644 --- a/tests/Algorithm/JobScheduling/WeightedTest.php +++ b/tests/Algorithm/JobScheduling/WeightedTest.php @@ -47,7 +47,7 @@ class WeightedTest extends \PHPUnit\Framework\TestCase foreach ($filtered as $job) { $value += $job->getValue(); - $names[] = $job->getName(); + $names[] = $job->name; } self::assertEqualsWithDelta(350, $value, 0.01); diff --git a/tests/Algorithm/PathFinding/GridTest.php b/tests/Algorithm/PathFinding/GridTest.php index 01f836696..4dd1108b0 100644 --- a/tests/Algorithm/PathFinding/GridTest.php +++ b/tests/Algorithm/PathFinding/GridTest.php @@ -78,7 +78,7 @@ class GridTest extends \PHPUnit\Framework\TestCase ], Node::class); $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)); } diff --git a/tests/Algorithm/PathFinding/NodeTest.php b/tests/Algorithm/PathFinding/NodeTest.php index b7251906c..3eec7ea24 100644 --- a/tests/Algorithm/PathFinding/NodeTest.php +++ b/tests/Algorithm/PathFinding/NodeTest.php @@ -38,8 +38,8 @@ class NodeTest extends \PHPUnit\Framework\TestCase self::assertEquals(2, $node->getY()); self::assertEquals(['x' => 1, 'y' => 2], $node->getCoordinates()); self::assertEquals(3.0, $node->getWeight()); - self::assertNull($node->getParent()); - self::assertFalse($node->isWalkable()); + self::assertNull($node->parent); + self::assertFalse($node->isWalkable); } /** @@ -78,7 +78,7 @@ class NodeTest extends \PHPUnit\Framework\TestCase $node = new Node(1, 2, 3.0, false); $node2 = new Node(2, 2, 3.0, false); - $node->setParent($node2); - self::assertTrue($node2->isEqual($node->getParent())); + $node->parent = $node2; + self::assertTrue($node2->isEqual($node->parent)); } } diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index edc44c909..289c2f41d 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -274,43 +274,49 @@ $CONFIG = [ ]; // Reset database -try { - $db = new \PDO($CONFIG['db']['core']['masters']['admin']['db'] . ':host=' . - $CONFIG['db']['core']['masters']['admin']['host'], - $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 = null; -} catch (\Throwable $t) { - echo "\nCouldn't connect to MYSQL DB\n"; +if (\extension_loaded('pdo_mysql')) { + try { + $db = new \PDO($CONFIG['db']['core']['masters']['admin']['db'] . ':host=' . + $CONFIG['db']['core']['masters']['admin']['host'], + $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 = null; + } catch (\Throwable $t) { + echo "\nCouldn't connect to MYSQL DB\n"; + } } -try { - $db = new \PDO($CONFIG['db']['core']['postgresql']['admin']['db'] . ':host=' . - $CONFIG['db']['core']['postgresql']['admin']['host'], - $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 = null; -} catch (\Throwable $t) { - echo "\nCouldn't connect to POSTGRESQL DB\n"; +if (\extension_loaded('pdo_pgsql')) { + try { + $db = new \PDO($CONFIG['db']['core']['postgresql']['admin']['db'] . ':host=' . + $CONFIG['db']['core']['postgresql']['admin']['host'], + $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 = null; + } catch (\Throwable $t) { + echo "\nCouldn't connect to POSTGRESQL DB\n"; + } } -try { - $db = new \PDO($CONFIG['db']['core']['mssql']['admin']['db'] . ':host=' . - $CONFIG['db']['core']['mssql']['admin']['host'], - $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 = null; -} catch (\Throwable $t) { - echo "\nCouldn't connect to MSSQL DB\n"; +if (\extension_loaded('pdo_sqlsrv')) { + try { + $db = new \PDO($CONFIG['db']['core']['mssql']['admin']['db'] . ':host=' . + $CONFIG['db']['core']['mssql']['admin']['host'], + $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 = null; + } catch (\Throwable $t) { + echo "\nCouldn't connect to MSSQL DB\n"; + } } $httpSession = new HttpSession(); diff --git a/tests/Event/EventManagerTest.php b/tests/Event/EventManagerTest.php index b899dd2bd..876306490 100644 --- a/tests/Event/EventManagerTest.php +++ b/tests/Event/EventManagerTest.php @@ -126,7 +126,7 @@ class EventManagerTest extends \PHPUnit\Framework\TestCase $this->event->addGroup('group', 'id1'); $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', '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', 'id2'); - self::assertFalse($this->event->triggerSimilar('group', '/id\d0/')); + self::assertFalse($this->event->triggerSimilar('group', '/id\\d0/')); } /** diff --git a/tests/Localization/LocalizationTest.php b/tests/Localization/LocalizationTest.php index 8f3622313..f7e66e1e1 100644 --- a/tests/Localization/LocalizationTest.php +++ b/tests/Localization/LocalizationTest.php @@ -47,7 +47,7 @@ class LocalizationTest extends \PHPUnit\Framework\TestCase { self::assertObjectHasAttribute('country', $this->localization); self::assertObjectHasAttribute('timezone', $this->localization); - self::assertObjectHasAttribute('lang', $this->localization); + self::assertObjectHasAttribute('language', $this->localization); self::assertObjectHasAttribute('currency', $this->localization); self::assertObjectHasAttribute('decimal', $this->localization); self::assertObjectHasAttribute('thousands', $this->localization); diff --git a/tests/Message/Console/ConsoleHeaderTest.php b/tests/Message/Console/ConsoleHeaderTest.php index 1db19abef..e6dfd1683 100644 --- a/tests/Message/Console/ConsoleHeaderTest.php +++ b/tests/Message/Console/ConsoleHeaderTest.php @@ -36,13 +36,13 @@ class ConsoleHeaderTest extends \PHPUnit\Framework\TestCase public function testDefaults() : void { 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('', $this->header->getReasonPhrase()); self::assertEquals([], $this->header->get('key')); self::assertFalse($this->header->has('key')); - self::assertInstanceOf(Localization::class, $this->header->getL11n()); - self::assertEquals(0, $this->header->getAccount()); + self::assertInstanceOf(Localization::class, $this->header->l11n); + self::assertEquals(0, $this->header->account); } /** @@ -105,8 +105,8 @@ class ConsoleHeaderTest extends \PHPUnit\Framework\TestCase */ public function testAccount() : void { - $this->header->setAccount(2); - self::AssertEquals(2, $this->header->getAccount(2)); + $this->header->account = 2; + self::AssertEquals(2, $this->header->account); } /** diff --git a/tests/Message/Console/ConsoleRequestTest.php b/tests/Message/Console/ConsoleRequestTest.php index a575eb55a..60c28594a 100644 --- a/tests/Message/Console/ConsoleRequestTest.php +++ b/tests/Message/Console/ConsoleRequestTest.php @@ -43,7 +43,7 @@ class ConsoleRequestTest extends \PHPUnit\Framework\TestCase self::assertEquals(OSType::LINUX, $request->getOS()); self::assertEquals('127.0.0.1', $request->getOrigin()); 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::assertFalse($request->hasData('key')); self::assertNull($request->getData('key')); @@ -75,7 +75,7 @@ class ConsoleRequestTest extends \PHPUnit\Framework\TestCase */ 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 { $l11n = new Localization(); - self::assertEquals($l11n, $this->request->getHeader()->getL11n()); + self::assertEquals($l11n, $this->request->header->l11n); } /** diff --git a/tests/Message/Console/ConsoleResponseTest.php b/tests/Message/Console/ConsoleResponseTest.php index e99033bb9..a233ba742 100644 --- a/tests/Message/Console/ConsoleResponseTest.php +++ b/tests/Message/Console/ConsoleResponseTest.php @@ -32,8 +32,8 @@ class ConsoleResponseTest extends \PHPUnit\Framework\TestCase self::assertEquals('', $response->getBody()); self::assertEquals('', $response->render()); self::assertEquals([], $response->toArray()); - self::assertInstanceOf('\phpOMS\Localization\Localization', $response->getHeader()->getL11n()); - self::assertInstanceOf('\phpOMS\Message\Console\ConsoleHeader', $response->getHeader()); + self::assertInstanceOf('\phpOMS\Localization\Localization', $response->header->l11n); + self::assertInstanceOf('\phpOMS\Message\Console\ConsoleHeader', $response->header); } /** diff --git a/tests/Message/HeaderAbstractTest.php b/tests/Message/HeaderAbstractTest.php index 2ae471a54..446d9b1d3 100644 --- a/tests/Message/HeaderAbstractTest.php +++ b/tests/Message/HeaderAbstractTest.php @@ -64,7 +64,7 @@ class HeaderAbstractTest extends \PHPUnit\Framework\TestCase */ public function testStatusCodeInputOutput() : void { - $this->header->setStatusCode(2); - self::assertEquals(2, $this->header->getStatusCode()); + $this->header->status = 2; + self::assertEquals(2, $this->header->status); } } diff --git a/tests/Message/Http/HttpHeaderTest.php b/tests/Message/Http/HttpHeaderTest.php index b3663d944..96304eab9 100644 --- a/tests/Message/Http/HttpHeaderTest.php +++ b/tests/Message/Http/HttpHeaderTest.php @@ -41,14 +41,14 @@ class HttpHeaderTest extends \PHPUnit\Framework\TestCase public function testDefaults() : void { 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::assertEmpty(HttpHeader::getAllHeaders()); self::assertEquals('', $this->header->getReasonPhrase()); self::assertEquals([], $this->header->get('key')); self::assertFalse($this->header->has('key')); - self::assertInstanceOf(Localization::class, $this->header->getL11n()); - self::assertEquals(0, $this->header->getAccount()); + self::assertInstanceOf(Localization::class, $this->header->l11n); + self::assertEquals(0, $this->header->account); } /** @@ -130,8 +130,8 @@ class HttpHeaderTest extends \PHPUnit\Framework\TestCase */ public function testAccountInputOutput() : void { - $this->header->setAccount(2); - self::assertEquals(2, $this->header->getAccount(2)); + $this->header->account = 2; + self::assertEquals(2, $this->header->account); } /** diff --git a/tests/Message/Http/HttpRequestTest.php b/tests/Message/Http/HttpRequestTest.php index 5c4b178cf..9f587e707 100644 --- a/tests/Message/Http/HttpRequestTest.php +++ b/tests/Message/Http/HttpRequestTest.php @@ -53,7 +53,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase self::assertEmpty($request->getFiles()); self::assertEquals(RouteVerb::GET, $request->getRouteVerb()); 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::assertEquals('http://', $request->__toString()); self::assertFalse($request->hasData('key')); @@ -152,7 +152,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', '328413d996ab9b79af9d4098af3a65b885c4ca64', ], $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->setMethod(RequestMethod::POST); - $request->getHeader()->set('Content-Type', MimeType::M_POST); + $request->header->set('Content-Type', MimeType::M_POST); $request->setData('testKey', 'testValue'); 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->setMethod(RequestMethod::POST); - $request->getHeader()->set('Content-Type', MimeType::M_JSON); + $request->header->set('Content-Type', MimeType::M_JSON); $request->setData('testKey', 'testValue'); 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->setMethod(RequestMethod::POST); - $request->getHeader()->set('Content-Type', MimeType::M_MULT); + $request->header->set('Content-Type', MimeType::M_MULT); $request->setData('testKey', 'testValue'); self::assertEquals( diff --git a/tests/Message/Http/HttpResponseTest.php b/tests/Message/Http/HttpResponseTest.php index 3597a6104..1bb5cd838 100644 --- a/tests/Message/Http/HttpResponseTest.php +++ b/tests/Message/Http/HttpResponseTest.php @@ -41,8 +41,8 @@ class ResponseTest extends \PHPUnit\Framework\TestCase self::assertEquals('', $this->response->getBody()); self::assertEquals('', $this->response->render()); self::assertEquals([], $this->response->toArray()); - self::assertInstanceOf('\phpOMS\Localization\Localization', $this->response->getHeader()->getL11n()); - self::assertInstanceOf('\phpOMS\Message\Http\HttpHeader', $this->response->getHeader()); + self::assertInstanceOf('\phpOMS\Localization\Localization', $this->response->header->l11n); + 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->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()); } @@ -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
text
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
text
that has \n whitespaces and \n\nnew lines\n ", $this->response->render(true)); } diff --git a/tests/Model/Html/HeadTest.php b/tests/Model/Html/HeadTest.php index 5948a905f..61898310e 100644 --- a/tests/Model/Html/HeadTest.php +++ b/tests/Model/Html/HeadTest.php @@ -38,8 +38,8 @@ class HeadTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertInstanceOf('\phpOMS\Model\Html\Meta', $this->head->getMeta()); - self::assertEquals('', $this->head->getTitle()); + self::assertInstanceOf('\phpOMS\Model\Html\Meta', $this->head->meta); + self::assertEquals('', $this->head->title); self::assertEquals('en', $this->head->getLanguage()); self::assertEquals([], $this->head->getStyleAll()); self::assertEquals([], $this->head->getScriptAll()); @@ -57,8 +57,8 @@ class HeadTest extends \PHPUnit\Framework\TestCase */ public function testTitleInputOutput() : void { - $this->head->setTitle('my title'); - self::assertEquals('my title', $this->head->getTitle()); + $this->head->title = 'my title'; + self::assertEquals('my title', $this->head->title); } /** diff --git a/tests/Model/Html/MetaTest.php b/tests/Model/Html/MetaTest.php index 4c4d0dcc1..4b4c164d1 100644 --- a/tests/Model/Html/MetaTest.php +++ b/tests/Model/Html/MetaTest.php @@ -37,9 +37,9 @@ class MetaTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertEquals('', $this->meta->getDescription()); + self::assertEquals('', $this->meta->description); self::assertEquals('', $this->meta->getCharset()); - self::assertEquals('', $this->meta->getAuthor()); + self::assertEquals('', $this->meta->author); self::assertEquals('', $this->meta->getName('')); self::assertEquals('', $this->meta->getProperty('')); self::assertEquals('', $this->meta->getItemprop('')); @@ -65,8 +65,8 @@ class MetaTest extends \PHPUnit\Framework\TestCase */ public function testAuthorInputOutput() : void { - $this->meta->setAuthor('oms'); - self::assertEquals('oms', $this->meta->getAuthor()); + $this->meta->author = 'oms'; + self::assertEquals('oms', $this->meta->author); } /** @@ -87,8 +87,8 @@ class MetaTest extends \PHPUnit\Framework\TestCase */ public function testDescriptionInputOutput() : void { - $this->meta->setDescription('some description'); - self::assertEquals('some description', $this->meta->getDescription()); + $this->meta->description = 'some description'; + self::assertEquals('some description', $this->meta->description); } /** @@ -132,9 +132,9 @@ class MetaTest extends \PHPUnit\Framework\TestCase public function testRender() : void { $this->meta->addKeyword('orange'); - $this->meta->setAuthor('oms'); + $this->meta->author = 'oms'; $this->meta->setCharset('utf-8'); - $this->meta->setDescription('some description'); + $this->meta->description = 'some description'; $this->meta->setProperty('og:title', 'TestProperty'); $this->meta->setItemprop('title', 'TestItemprop'); $this->meta->setName('title', 'TestName'); diff --git a/tests/Router/WebRouterTest.php b/tests/Router/WebRouterTest.php index 0a3965ba3..28e68037c 100644 --- a/tests/Router/WebRouterTest.php +++ b/tests/Router/WebRouterTest.php @@ -50,7 +50,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase { self::assertEmpty( $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( (new HttpRequest( 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( (new HttpRequest( 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( (new HttpRequest( new HttpUri('http://test.com/backends/admin/settings/general/something?test') - ))->getUri()->getRoute(), null, RouteVerb::ANY) + ))->uri->getRoute(), null, RouteVerb::ANY) ); self::assertEquals( @@ -133,14 +133,14 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase $this->router->route( (new HttpRequest( new HttpUri('http://test.com/backends/admin/settings/general/something?test') - ))->getUri()->getRoute(), null, RouteVerb::SET) + ))->uri->getRoute(), null, RouteVerb::SET) ); self::assertEquals( [['dest' => 'Controller:test']], $this->router->route( (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( (new HttpRequest( new HttpUri('http://test.com/backend/admin/settings/csrf/something?test') - ))->getUri()->getRoute(), + ))->uri->getRoute(), 'csrf_string' ) ); @@ -178,7 +178,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase $this->router->route( (new HttpRequest( 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( [['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']], $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, RouteVerb::GET, null, @@ -277,7 +277,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase self::assertNotEquals( [['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']], $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, RouteVerb::GET, null, @@ -307,7 +307,7 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase $this->router->route( (new HttpRequest( 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( (new HttpRequest( 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( (new HttpRequest( new HttpUri('http://test.com/backends/admin?something=123&sd=asdf') - ))->getUri()->getRoute(), null, RouteVerb::ANY) + ))->uri->getRoute(), null, RouteVerb::ANY) ); } } diff --git a/tests/Stdlib/Base/AddressTest.php b/tests/Stdlib/Base/AddressTest.php index a59a68a08..d21b8d84e 100644 --- a/tests/Stdlib/Base/AddressTest.php +++ b/tests/Stdlib/Base/AddressTest.php @@ -66,9 +66,9 @@ class AddressTest extends \PHPUnit\Framework\TestCase ], ]; - self::assertEquals('', $this->address->getRecipient()); - self::assertEquals('', $this->address->getFAO()); - self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address->getLocation()); + self::assertEquals('', $this->address->recipient); + self::assertEquals('', $this->address->fao); + self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address->location); self::assertEquals($expected, $this->address->toArray()); self::assertEquals($expected, $this->address->jsonSerialize()); } @@ -80,8 +80,8 @@ class AddressTest extends \PHPUnit\Framework\TestCase */ public function testFAOInputOutput() : void { - $this->address->setFAO('fao'); - self::assertEquals('fao', $this->address->getFAO()); + $this->address->fao = 'fao'; + self::assertEquals('fao', $this->address->fao); } /** @@ -91,8 +91,8 @@ class AddressTest extends \PHPUnit\Framework\TestCase */ public function testRecipientInputOutput() : void { - $this->address->setRecipient('recipient'); - self::assertEquals('recipient', $this->address->getRecipient()); + $this->address->recipient = 'recipient'; + self::assertEquals('recipient', $this->address->recipient); } /** @@ -102,9 +102,9 @@ class AddressTest extends \PHPUnit\Framework\TestCase */ 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->setRecipient('recipient'); - $this->address->setLocation(new Location()); + $this->address->fao = 'fao'; + $this->address->recipient = 'recipient'; + $this->address->location = new Location(); self::assertEquals($expected, $this->address->toArray()); } @@ -160,9 +160,9 @@ class AddressTest extends \PHPUnit\Framework\TestCase ], ]; - $this->address->setFAO('fao'); - $this->address->setRecipient('recipient'); - $this->address->setLocation(new Location()); + $this->address->fao = 'fao'; + $this->address->recipient = 'recipient'; + $this->address->location = new Location(); self::assertEquals($expected, $this->address->jsonSerialize()); } diff --git a/tests/Stdlib/Base/LocationTest.php b/tests/Stdlib/Base/LocationTest.php index 35b19c1e4..b0d954d06 100644 --- a/tests/Stdlib/Base/LocationTest.php +++ b/tests/Stdlib/Base/LocationTest.php @@ -65,11 +65,11 @@ class LocationTest extends \PHPUnit\Framework\TestCase ], ]; - self::assertEquals('', $this->location->getPostal()); - self::assertEquals('', $this->location->getCity()); + self::assertEquals('', $this->location->postal); + self::assertEquals('', $this->location->city); self::assertEquals('US', $this->location->getCountry()); - self::assertEquals('', $this->location->getAddress()); - self::assertEquals('', $this->location->getState()); + self::assertEquals('', $this->location->address); + self::assertEquals('', $this->location->state); self::assertEquals(0, $this->location->getId()); self::assertEquals(AddressType::HOME, $this->location->getType()); self::assertEquals(['lat' => 0, 'long' => 0], $this->location->getGeo()); @@ -84,8 +84,8 @@ class LocationTest extends \PHPUnit\Framework\TestCase */ public function testPostalInputOutput() : void { - $this->location->setPostal('0123456789'); - self::assertEquals('0123456789', $this->location->getPostal()); + $this->location->postal = '0123456789'; + self::assertEquals('0123456789', $this->location->postal); } /** @@ -106,8 +106,8 @@ class LocationTest extends \PHPUnit\Framework\TestCase */ public function testCityInputOutput() : void { - $this->location->setCity('city'); - self::assertEquals('city', $this->location->getCity()); + $this->location->city = 'city'; + self::assertEquals('city', $this->location->city); } /** @@ -128,8 +128,8 @@ class LocationTest extends \PHPUnit\Framework\TestCase */ public function testAddressInputOutput() : void { - $this->location->setAddress('Some address here'); - self::assertEquals('Some address here', $this->location->getAddress()); + $this->location->address = 'Some address here'; + self::assertEquals('Some address here', $this->location->address); } /** @@ -139,8 +139,8 @@ class LocationTest extends \PHPUnit\Framework\TestCase */ public function testStateInputOutput() : void { - $this->location->setState('This is a state 123'); - self::assertEquals('This is a state 123', $this->location->getState()); + $this->location->state = 'This is a state 123'; + 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->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->setAddress('Some address here'); - $this->location->setState('This is a state 123'); $this->location->setGeo(['lat' => 12.1, 'long' => 11.2,]); 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->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->setAddress('Some address here'); - $this->location->setState('This is a state 123'); $this->location->setGeo(['lat' => 12.1, 'long' => 11.2,]); self::assertEquals($expected, $this->location->jsonSerialize()); diff --git a/tests/System/File/Local/FileTest.php b/tests/System/File/Local/FileTest.php index d2ff711df..9e2fedf54 100644 --- a/tests/System/File/Local/FileTest.php +++ b/tests/System/File/Local/FileTest.php @@ -852,7 +852,7 @@ class FileTest extends \PHPUnit\Framework\TestCase $file->createNode(); $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); } diff --git a/tests/Uri/ArgumentTest.php b/tests/Uri/ArgumentTest.php index bf3ea41b0..876354552 100644 --- a/tests/Uri/ArgumentTest.php +++ b/tests/Uri/ArgumentTest.php @@ -50,11 +50,11 @@ class ArgumentTest extends \PHPUnit\Framework\TestCase self::assertEquals('/', $obj->getRootPath()); self::assertEquals(0, $obj->getPathOffset()); - self::assertEquals('', $obj->getScheme()); - self::assertEquals('', $obj->getHost()); - self::assertEquals(0, $obj->getPort()); - self::assertEquals('', $obj->getPass()); - self::assertEquals('', $obj->getUser()); + self::assertEquals('', $obj->scheme); + self::assertEquals('', $obj->host); + self::assertEquals(0, $obj->port); + self::assertEquals('', $obj->pass); + self::assertEquals('', $obj->user); self::assertEquals('', $obj->getAuthority()); self::assertEquals('', $obj->getUserInfo()); 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->setScheme('scheme'); - self::assertEquals('scheme', $obj->getScheme()); + $obj->scheme = 'scheme'; + 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->setUser('user'); - self::assertEquals('user', $obj->getUser()); + $obj->user = 'user'; + 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->setPass('pass'); - self::assertEquals('pass', $obj->getPass()); + $obj->pass = 'pass'; + 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->setHost('host'); - self::assertEquals('host', $obj->getHost()); + $obj->host = 'host'; + 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->setPort(123); - self::assertEquals(123, $obj->getPort()); + $obj->port = 123; + 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'); - self::assertEquals('frag', $obj->getFragment()); + self::assertEquals('frag', $obj->fragment); - $obj->setFragment('frag2'); - self::assertEquals('frag2', $obj->getFragment()); + $obj->fragment = 'frag2'; + self::assertEquals('frag2', $obj->fragment); } /** diff --git a/tests/Uri/HttpUriTest.php b/tests/Uri/HttpUriTest.php index 84e6cd991..89d9c7e37 100644 --- a/tests/Uri/HttpUriTest.php +++ b/tests/Uri/HttpUriTest.php @@ -47,9 +47,9 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase { $obj = new HttpUri('https://www.google.com/test/path.php?para1=abc¶2=2#frag'); - self::assertEquals('', $obj->getPass()); - self::assertEquals('', $obj->getUser()); - self::assertEquals(80, $obj->getPort()); + self::assertEquals('', $obj->pass); + self::assertEquals('', $obj->user); + self::assertEquals(80, $obj->port); self::assertEquals('', $obj->getUserInfo()); self::assertEquals('', $obj->getRootPath()); 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¶2=2#frag'); - self::assertEquals('https', $obj->getScheme()); + self::assertEquals('https', $obj->scheme); - $obj->setScheme('ftp'); - self::assertEquals('ftp', $obj->getScheme()); + $obj->scheme = 'ftp'; + 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¶2=2#frag'); - self::assertEquals(21, $obj->getPort()); + self::assertEquals(21, $obj->port); - $obj->setPort(123); - self::assertEquals(123, $obj->getPort()); + $obj->port = 123; + 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¶2=2#frag'); - self::assertEquals('www.google.com', $obj->getHost()); + self::assertEquals('www.google.com', $obj->host); - $obj->setHost('127.0.0.1'); - self::assertEquals('127.0.0.1', $obj->getHost()); + $obj->host = '127.0.0.1'; + 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¶2=2#frag'); - self::assertEquals('username', $obj->getUser()); + self::assertEquals('username', $obj->user); - $obj->setUser('user'); - self::assertEquals('user', $obj->getUser()); + $obj->user = 'user'; + 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¶2=2#frag'); - self::assertEquals('password', $obj->getPass()); + self::assertEquals('password', $obj->pass); - $obj->setPass('pass'); - self::assertEquals('pass', $obj->getPass()); + $obj->pass = 'pass'; + self::assertEquals('pass', $obj->pass); } /** @@ -253,10 +253,10 @@ class HttpUriTest extends \PHPUnit\Framework\TestCase public function testFragment() : void { $obj = new HttpUri('https://www.google.com/test/path.php?para1=abc¶2=2#frag'); - self::assertEquals('frag', $obj->getFragment()); + self::assertEquals('frag', $obj->fragment); - $obj->setFragment('frag2'); - self::assertEquals('frag2', $obj->getFragment()); + $obj->fragment = 'frag2'; + 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'); self::assertEquals('', $obj->getPath()); - self::assertEquals('', $obj->getPass()); - self::assertEquals('', $obj->getUser()); - self::assertEquals(80, $obj->getPort()); + self::assertEquals('', $obj->pass); + self::assertEquals('', $obj->user); + self::assertEquals(80, $obj->port); self::assertEquals('', $obj->getUserInfo()); self::assertEquals('', $obj->getRootPath()); } diff --git a/tests/Uri/UriFactoryTest.php b/tests/Uri/UriFactoryTest.php index 046d89c6d..903970e8d 100644 --- a/tests/Uri/UriFactoryTest.php +++ b/tests/Uri/UriFactoryTest.php @@ -161,7 +161,7 @@ class UriFactoryTest extends \PHPUnit\Framework\TestCase */ 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 = [ '@ID' => 1, @@ -172,7 +172,7 @@ class UriFactoryTest extends \PHPUnit\Framework\TestCase 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)); } diff --git a/tests/Utils/Git/AuthorTest.php b/tests/Utils/Git/AuthorTest.php index 6b58b6375..96229b517 100644 --- a/tests/Utils/Git/AuthorTest.php +++ b/tests/Utils/Git/AuthorTest.php @@ -31,7 +31,7 @@ class AuthorTest extends \PHPUnit\Framework\TestCase public function testDefault() : void { $author = new Author(); - self::assertEquals('', $author->getName()); + self::assertEquals('', $author->name); self::assertEquals('', $author->getEmail()); self::assertEquals(0, $author->getCommitCount()); self::assertEquals(0, $author->getAdditionCount()); @@ -46,7 +46,7 @@ class AuthorTest extends \PHPUnit\Framework\TestCase public function testConstructInputOutput() : void { $author = new Author('test', 'email'); - self::assertEquals('test', $author->getName()); + self::assertEquals('test', $author->name); self::assertEquals('email', $author->getEmail()); } diff --git a/tests/Utils/Git/BranchTest.php b/tests/Utils/Git/BranchTest.php index e0436d55d..a6a8d0752 100644 --- a/tests/Utils/Git/BranchTest.php +++ b/tests/Utils/Git/BranchTest.php @@ -31,7 +31,7 @@ class BranchTest extends \PHPUnit\Framework\TestCase public function testDefault() : void { $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 { $branch = new Branch('test'); - self::assertEquals('test', $branch->getName()); + self::assertEquals('test', $branch->name); } } diff --git a/tests/Utils/Git/CommitTest.php b/tests/Utils/Git/CommitTest.php index 95cb140cb..1e392e2e9 100644 --- a/tests/Utils/Git/CommitTest.php +++ b/tests/Utils/Git/CommitTest.php @@ -163,7 +163,7 @@ class CommitTest extends \PHPUnit\Framework\TestCase $commit = new Commit(); $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->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->setTag(new Tag('1.0.0')); - self::assertEquals('1.0.0', $commit->getTag()->getName()); + self::assertEquals('1.0.0', $commit->getTag()->name); } /** diff --git a/tests/Views/ViewTest.php b/tests/Views/ViewTest.php index 2853b2560..f1fff0f40 100644 --- a/tests/Views/ViewTest.php +++ b/tests/Views/ViewTest.php @@ -263,8 +263,8 @@ class ViewTest extends \PHPUnit\Framework\TestCase { $view = new View($this->app->l11nManager, $request = new HttpRequest(new HttpUri('')), $response = new HttpResponse()); - self::assertEquals($request, $view->getRequest()); - self::assertEquals($response, $view->getResponse()); + self::assertEquals($request, $view->request); + 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()); - self::assertEquals($response, $view->getResponse()); + self::assertEquals($response, $view->response); } /**