diff --git a/Auth/Auth.php b/Auth/Auth.php index 0f1a06395..d75b9413c 100644 --- a/Auth/Auth.php +++ b/Auth/Auth.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace phpOMS\Auth; -use phpOMS\DataStorage\Database\Connection\ConnectionAbstract; use phpOMS\DataStorage\Session\SessionInterface; /** diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index 8c2edfff5..eeedc7a40 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -16,7 +16,6 @@ declare(strict_types=1); namespace phpOMS\Message; use phpOMS\Stdlib\Base\Exception\InvalidEnumValue; -use phpOMS\Localization\Localization; use phpOMS\Uri\UriInterface; /** diff --git a/Module/PackageManager.php b/Module/PackageManager.php index d743e1fcf..b7271ba02 100644 --- a/Module/PackageManager.php +++ b/Module/PackageManager.php @@ -16,7 +16,6 @@ declare(strict_types=1); namespace phpOMS\Module; use phpOMS\System\File\PathException; -use phpOMS\Utils\ArrayUtils; use phpOMS\System\File\Local\File; use phpOMS\System\File\Local\Directory; use phpOMS\System\File\Local\LocalStorage; diff --git a/Stdlib/Graph/BinaryTree.php b/Stdlib/Graph/BinaryTree.php index bd8f5f233..b9b04c25d 100644 --- a/Stdlib/Graph/BinaryTree.php +++ b/Stdlib/Graph/BinaryTree.php @@ -28,98 +28,98 @@ namespace phpOMS\Stdlib\Graph; */ class BinaryTree extends Tree { - public static function invert($list) : BinaryTree - { - if (empty($list->getNodes())) { - return $list; - } + public static function invert($list) : BinaryTree + { + if (empty($list->getNodes())) { + return $list; + } - $left = $list->getLeft(); - $list->setLeft($list->invert($list->nodes[1])); - $list->setRight($list->invert($left)); + $left = $list->getLeft(); + $list->setLeft($list->invert($list->nodes[1])); + $list->setRight($list->invert($left)); - return $list; - } + return $list; + } - /** + /** * Get left node of a node. * * @param Node $base Tree node - * - * @return Node Left node + * + * @return Node Left node * * @since 1.0.0 */ - public function getLeft(Node $base) - { - $neighbors = $base->getNeighbors($base); + public function getLeft(Node $base) + { + $neighbors = $base->getNeighbors($base); - // todo: index can be wrong, see setLeft/setRight - return $neighbors[0] ?? null; - } + // todo: index can be wrong, see setLeft/setRight + return $neighbors[0] ?? null; + } - /** + /** * Get right node of a node. * * @param Node $base Tree node - * - * @return Node Right node + * + * @return Node Right node * * @since 1.0.0 */ - public function getRight(Node $base) - { - $neighbors = $this->getNeighbors($base); + public function getRight(Node $base) + { + $neighbors = $this->getNeighbors($base); - // todo: index can be wrong, see setLeft/setRight - return $neighbors[1] ?? null; - } + // todo: index can be wrong, see setLeft/setRight + return $neighbors[1] ?? null; + } - /** + /** * Set left node of node. * * @param Node $base Base node * @param Node $left Left node - * - * @return BinaryTree + * + * @return BinaryTree * * @since 1.0.0 */ - public function setLeft(Node $base, Node $left) : BinaryTree - { - if($this->getLeft($base) === null) { - $this->addNodeRelative($base, $left); - // todo: doesn't know that this is left - // todo: maybe need to add numerics to edges? - } else { - // todo: replace node - } + public function setLeft(Node $base, Node $left) : BinaryTree + { + if($this->getLeft($base) === null) { + $this->addNodeRelative($base, $left); + // todo: doesn't know that this is left + // todo: maybe need to add numerics to edges? + } else { + // todo: replace node + } - return $this; - } + return $this; + } - /** + /** * Set right node of node. * * @param Node $base Base node * @param Node $right Right node - * - * @return BinaryTree + * + * @return BinaryTree * * @since 1.0.0 */ - public function setRight(Node $base, Node $right) /* : void */ - { - if($this->getRight($base) === null) { - $this->addNodeRelative($base, $right); - // todo: doesn't know that this is right - // todo: maybe need to add numerics to edges? - } else { - // todo: replace node - } - } + public function setRight(Node $base, Node $right) /* : void */ + { + if($this->getRight($base) === null) { + $this->addNodeRelative($base, $right); + // todo: doesn't know that this is right + // todo: maybe need to add numerics to edges? + } else { + // todo: replace node + } + } - /** + /** * Perform action on tree in in-order. * * @param Node $node Tree node @@ -127,42 +127,42 @@ class BinaryTree extends Tree * * @since 1.0.0 */ - public function inOrder(Node $node, \Closure $callback) - { - $this->inOrder($this->getLeft($node), $callback); - $callback($node); - $this->inOrder($this->getRight($node), $callback); - } + public function inOrder(Node $node, \Closure $callback) + { + $this->inOrder($this->getLeft($node), $callback); + $callback($node); + $this->inOrder($this->getRight($node), $callback); + } - /** + /** * Get nodes in vertical order. * * @param Node $node Tree node * @param int $horizontalDistance Horizontal distance - * @param Node[] &$order Ordered nodes by horizontal distance + * @param Node[] &$order Ordered nodes by horizontal distance * * @since 1.0.0 */ - private function getVerticalOrder(Node $node, int $horizontalDistance = 0, array &$order) - { - if(!isset($order[$horizontalDistance])) { - $order[$horizontalDistance] = []; - } + private function getVerticalOrder(Node $node, int $horizontalDistance = 0, array &$order) + { + if(!isset($order[$horizontalDistance])) { + $order[$horizontalDistance] = []; + } - $order[$horizontalDistance][] = $node; - $left = $this->getLeft($node); - $right = $this->getRight($node); + $order[$horizontalDistance][] = $node; + $left = $this->getLeft($node); + $right = $this->getRight($node); - if(isset($left)) { - $this->getVerticalOrder($left, $horizontalDistance-1, $order); - } + if(isset($left)) { + $this->getVerticalOrder($left, $horizontalDistance-1, $order); + } - if(isset($right)) { - $this->getVerticalOrder($right, $horizontalDistance+1, $order); - } - } + if(isset($right)) { + $this->getVerticalOrder($right, $horizontalDistance+1, $order); + } + } - /** + /** * Perform action on tree in vertical-order. * * @param Node $node Tree node @@ -170,45 +170,45 @@ class BinaryTree extends Tree * * @since 1.0.0 */ - public function verticalOrder(Node $node, \Closure $callback) - { - $order = []; - $this->getVerticalOrder($node, 0, $order); + public function verticalOrder(Node $node, \Closure $callback) + { + $order = []; + $this->getVerticalOrder($node, 0, $order); - foreach($order as $level) { - foreach($level as $node) { - $callback($node); - } - } - } + foreach($order as $level) { + foreach($level as $node) { + $callback($node); + } + } + } - /** + /** * Check if tree is symmetric. * * @param Node $node1 Tree node1 * @param Node $node2 Tree node2 (optional, can be different tree) - * - * @return bool True if tree is symmetric, false if tree is not symmetric + * + * @return bool True if tree is symmetric, false if tree is not symmetric * * @since 1.0.0 */ - public function isSymmetric(Node $node1 = null, Node $node2 = null) : bool - { - if(!isset($node1) && !isset($node2)) { - return true; - } + public function isSymmetric(Node $node1 = null, Node $node2 = null) : bool + { + if(!isset($node1) && !isset($node2)) { + return true; + } - $left1 = $this->getLeft($node1); - $right1 = $this->getRight($node1); + $left1 = $this->getLeft($node1); + $right1 = $this->getRight($node1); - $left2 = isset($node2) ? $this->getLeft($node1) : $this->getLeft($node2); - $right2 = isset($node2) ? $this->getRight($node1) : $this->getRight($node2); + $left2 = isset($node2) ? $this->getLeft($node1) : $this->getLeft($node2); + $right2 = isset($node2) ? $this->getRight($node1) : $this->getRight($node2); - // todo: compare values? true symmetry requires the values to be the same - if(isset($node1, $node2)) { - return $this->isSymmetric($left1, $right2) && $this->isSymmetric($right1, $left2); - } + // todo: compare values? true symmetry requires the values to be the same + if(isset($node1, $node2)) { + return $this->isSymmetric($left1, $right2) && $this->isSymmetric($right1, $left2); + } - return false; - } + return false; + } } \ No newline at end of file diff --git a/Stdlib/Graph/Tree.php b/Stdlib/Graph/Tree.php index 7c6a439af..a30cdc0db 100644 --- a/Stdlib/Graph/Tree.php +++ b/Stdlib/Graph/Tree.php @@ -26,26 +26,26 @@ namespace phpOMS\Stdlib\Graph; */ class Tree extends Graph { - /** + /** * Root node. * * @var Node * @since 1.0.0 */ - private $root = null; + private $root = null; - /** + /** * Constructor. * * @since 1.0.0 */ - public function __construct() - { - $root = new Node(); - parent::addNode($root); - } + public function __construct() + { + $root = new Node(); + parent::addNode($root); + } - /** + /** * Add a note relative to a node. * * @param Node $base Base node @@ -55,15 +55,15 @@ class Tree extends Graph * * @since 1.0.0 */ - public function addRelativeNode(Node $base, Node $node) : Tree - { - parent::addNode($node); - parent::addEdge(new Edge($base, $node)); + public function addRelativeNode(Node $base, Node $node) : Tree + { + parent::addNode($node); + parent::addEdge(new Edge($base, $node)); - return $this; - } + return $this; + } - /** + /** * Get maximum tree depth. * * @param Node $node Tree node @@ -72,25 +72,25 @@ class Tree extends Graph * * @since 1.0.0 */ - public function getMaxDepth(Node $node = null) : int - { - $currentNode = $node ?? $this->root; + public function getMaxDepth(Node $node = null) : int + { + $currentNode = $node ?? $this->root; - if(!isset($currentNode)) { - return 0; - } + if(!isset($currentNode)) { + return 0; + } - $depth = 1; - $neighbors = $this->getNeighbors($currentNode); + $depth = 1; + $neighbors = $this->getNeighbors($currentNode); - foreach($neighbors as $neighbor) { - $depth = max($depth, $depth + $this->getMaxDepth($neighbor)); - } + foreach($neighbors as $neighbor) { + $depth = max($depth, $depth + $this->getMaxDepth($neighbor)); + } - return $depth; - } + return $depth; + } - /** + /** * Get minimum tree path. * * @param Node $node Tree node @@ -99,27 +99,27 @@ class Tree extends Graph * * @since 1.0.0 */ - public function getMinDepth(Node $node = null) : int - { - $currentNode = $node ?? $this->root; + public function getMinDepth(Node $node = null) : int + { + $currentNode = $node ?? $this->root; - if(!isset($currentNode)) { - return 0; - } + if(!isset($currentNode)) { + return 0; + } - $depth = []; - $neighbors = $this->getNeighbors($currentNode); + $depth = []; + $neighbors = $this->getNeighbors($currentNode); - foreach($neighbors as $neighbor) { - $depth[] = $this->getMaxDepth($neighbor); - } + foreach($neighbors as $neighbor) { + $depth[] = $this->getMaxDepth($neighbor); + } - $depth = empty($depth) ? 0 : $depth; + $depth = empty($depth) ? 0 : $depth; - return min($depth) + 1; - } + return min($depth) + 1; + } - /** + /** * Perform task on tree nodes in level order. * * @param Node $node Tree node @@ -129,17 +129,17 @@ class Tree extends Graph * * @since 1.0.0 */ - public function levelOrder(Node $node, \Closure $callback) - { - $depth = $this->getMaxDepth(); + public function levelOrder(Node $node, \Closure $callback) + { + $depth = $this->getMaxDepth(); - for($i = 1; $i < $depth; $i++) { - $nodes = $this->getLevel($i); - callback($nodes); - } - } + for($i = 1; $i < $depth; $i++) { + $nodes = $this->getLevel($i); + callback($nodes); + } + } - /** + /** * Check if node is leaf. * * @param Node $node Tree node @@ -148,12 +148,12 @@ class Tree extends Graph * * @since 1.0.0 */ - public function isLeaf(Node $node) : bool - { - return count($this->getEdgesOfNode($node)) === 1; - } + public function isLeaf(Node $node) : bool + { + return count($this->getEdgesOfNode($node)) === 1; + } - /** + /** * Get all nodes of a specific level. * * @param int $level Level to retrieve @@ -163,24 +163,24 @@ class Tree extends Graph * * @since 1.0.0 */ - public function getLevelNodes(int $level, Node $node) : array - { - --$level; - $neighbors = $this->getNeighbors($node); - $nodes = []; + public function getLevelNodes(int $level, Node $node) : array + { + --$level; + $neighbors = $this->getNeighbors($node); + $nodes = []; - if($level === 1) { - return $neighbors; - } + if($level === 1) { + return $neighbors; + } - foreach($neighbors as $neighbor) { - array_merge($nodes, $this->getLevelNodes($level, $neighbor)); - } + foreach($neighbors as $neighbor) { + array_merge($nodes, $this->getLevelNodes($level, $neighbor)); + } - return $nodes; - } + return $nodes; + } - /** + /** * Check if the tree is full. * * @param int $type Child nodes per non-leaf node @@ -189,24 +189,24 @@ class Tree extends Graph * * @since 1.0.0 */ - public function isFull(int $type) : bool - { - if(count($this->edges) % $type !== 0) { - return false; - } + public function isFull(int $type) : bool + { + if(count($this->edges) % $type !== 0) { + return false; + } - foreach($this->nodes as $node) { - $neighbors = count($this->getNeighbors($node)); + foreach($this->nodes as $node) { + $neighbors = count($this->getNeighbors($node)); - if($neighbors !== $type && $neighbors !== 0) { - return false; - } - } + if($neighbors !== $type && $neighbors !== 0) { + return false; + } + } - return true; - } + return true; + } - /** + /** * Perform action on tree in pre-order. * * @param Node $node Tree node @@ -214,21 +214,21 @@ class Tree extends Graph * * @since 1.0.0 */ - public function preOrder(Node $node, \Closure $callback) { - if(count($this->nodes) === 0) { - return; - } + public function preOrder(Node $node, \Closure $callback) { + if(count($this->nodes) === 0) { + return; + } - $callback($node); - $neighbors = $this->getNeighbors($node); + $callback($node); + $neighbors = $this->getNeighbors($node); - foreach($neighbors as $neighbor) { - // todo: get neighbors needs to return in ordered way - $this->preOrder($neighbor, $callback); - } - } + foreach($neighbors as $neighbor) { + // todo: get neighbors needs to return in ordered way + $this->preOrder($neighbor, $callback); + } + } - /** + /** * Perform action on tree in post-order. * * @param Node $node Tree node @@ -236,18 +236,18 @@ class Tree extends Graph * * @since 1.0.0 */ - public function postOrder(Node $node, \Closure $callback) { - if(count($this->nodes) === 0) { - return; - } + public function postOrder(Node $node, \Closure $callback) { + if(count($this->nodes) === 0) { + return; + } - $neighbors = $this->getNeighbors($node); + $neighbors = $this->getNeighbors($node); - foreach($neighbors as $neighbor) { - // todo: get neighbors needs to return in ordered way - $this->postOrder($neighbor, $callback); - } + foreach($neighbors as $neighbor) { + // todo: get neighbors needs to return in ordered way + $this->postOrder($neighbor, $callback); + } - $callback($node); - } + $callback($node); + } } \ No newline at end of file diff --git a/System/File/FileInterface.php b/System/File/FileInterface.php index 3788fa189..b794a81b5 100644 --- a/System/File/FileInterface.php +++ b/System/File/FileInterface.php @@ -29,7 +29,7 @@ namespace phpOMS\System\File; interface FileInterface extends ContainerInterface { - /** + /** * Save content to file. * * @param string $path File path to save the content to @@ -106,7 +106,7 @@ interface FileInterface extends ContainerInterface */ public static function extension(string $path) : string; - /** + /** * Save content to file. * * @param string $content Content to save in file diff --git a/System/File/Local/LocalStorage.php b/System/File/Local/LocalStorage.php index ea248c7f5..8ca0fb2be 100644 --- a/System/File/Local/LocalStorage.php +++ b/System/File/Local/LocalStorage.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace phpOMS\System\File\Local; -use phpOMS\System\File\ContainerInterface; use phpOMS\System\File\StorageAbstract; use phpOMS\System\File\PathException;