@@ -90,19 +90,19 @@ |
||
| 90 | 90 | */ |
| 91 | 91 | public function isSuitableVertex(VertexInterface $vertex): bool |
| 92 | 92 | { |
| 93 | - if($this->vertexTypesOnly !== null && !in_array($vertex->getType(), $this->vertexTypesOnly)) { |
|
| 93 | + if ($this->vertexTypesOnly !== null && !in_array($vertex->getType(), $this->vertexTypesOnly)) { |
|
| 94 | 94 | return false; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if($this->vertexIdsOnly !== null && !in_array($vertex->getId(), $this->vertexIdsOnly)) { |
|
| 97 | + if ($this->vertexIdsOnly !== null && !in_array($vertex->getId(), $this->vertexIdsOnly)) { |
|
| 98 | 98 | return false; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if(in_array($vertex->getType(), $this->vertexTypesExclude)) { |
|
| 101 | + if (in_array($vertex->getType(), $this->vertexTypesExclude)) { |
|
| 102 | 102 | return false; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if(in_array($vertex->getId(), $this->vertexIdsExclude)) { |
|
| 105 | + if (in_array($vertex->getId(), $this->vertexIdsExclude)) { |
|
| 106 | 106 | return false; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -27,8 +27,8 @@ |
||
| 27 | 27 | public static function combine(TraverseStepIteratorInterface ...$iterators): TraverseStepIteratorInterface |
| 28 | 28 | { |
| 29 | 29 | $source = []; |
| 30 | - foreach($iterators as $iterator) { |
|
| 31 | - foreach($iterator as $edge => $vertex) { |
|
| 30 | + foreach ($iterators as $iterator) { |
|
| 31 | + foreach ($iterator as $edge => $vertex) { |
|
| 32 | 32 | $source[] = new TraverseStepItem($edge, $vertex); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | public static function getBranches(Generator $contexts, ?callable $callback = null): array |
| 22 | 22 | { |
| 23 | 23 | $branchMap = []; |
| 24 | - foreach($contexts as $context) { |
|
| 25 | - if(is_callable($callback)) { |
|
| 24 | + foreach ($contexts as $context) { |
|
| 25 | + if (is_callable($callback)) { |
|
| 26 | 26 | $callback($context, $contexts); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | $parentBranchIndex = $context->getBranchContext()->getParentIndex(); |
| 32 | 32 | $vertex = $context->getVertex(); |
| 33 | 33 | |
| 34 | - if(!isset($branchMap[$branchIndex])) { |
|
| 35 | - if(isset($branchMap[$parentBranchIndex])) { |
|
| 34 | + if (!isset($branchMap[$branchIndex])) { |
|
| 35 | + if (isset($branchMap[$parentBranchIndex])) { |
|
| 36 | 36 | $parentBranch = $branchMap[$parentBranchIndex]; |
| 37 | 37 | $key = array_search($branchContext->getStart(), $parentBranch); |
| 38 | 38 | $branchMap[$branchIndex] = array_slice($parentBranch, 0, $key+1); |
@@ -54,11 +54,11 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | public function isSuitableEdge(EdgeInterface $edge): bool |
| 56 | 56 | { |
| 57 | - if($this->edgeTypesOnly !== null && !in_array($edge->getType(), $this->edgeTypesOnly)) { |
|
| 57 | + if ($this->edgeTypesOnly !== null && !in_array($edge->getType(), $this->edgeTypesOnly)) { |
|
| 58 | 58 | return false; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if(in_array($edge->getType(), $this->edgeTypesExclude)) { |
|
| 61 | + if (in_array($edge->getType(), $this->edgeTypesExclude)) { |
|
| 62 | 62 | return false; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | array $vertexes, |
| 40 | 40 | array $edges |
| 41 | 41 | ) { |
| 42 | - foreach($vertexes as $vertex) { |
|
| 42 | + foreach ($vertexes as $vertex) { |
|
| 43 | 43 | $this->vertexMap[$vertex->getId()] = $vertex; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - foreach($edges as $edge) { |
|
| 46 | + foreach ($edges as $edge) { |
|
| 47 | 47 | $this->edgesMap[$edge->getId()] = $edge; |
| 48 | 48 | |
| 49 | 49 | NestedHelper::set( |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function getVertexById(string $id): VertexInterface |
| 68 | 68 | { |
| 69 | - if(!isset($this->vertexMap[$id])) { |
|
| 69 | + if (!isset($this->vertexMap[$id])) { |
|
| 70 | 70 | throw new RepositoryException( |
| 71 | 71 | "vertex with id '{$id}' not exist", |
| 72 | 72 | RepositoryException::VERTEX_NOT_FOUND |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function getEdgeById(string $id): EdgeInterface |
| 83 | 83 | { |
| 84 | - if(!isset($this->edgesMap[$id])) { |
|
| 84 | + if (!isset($this->edgesMap[$id])) { |
|
| 85 | 85 | throw new RepositoryException( |
| 86 | 86 | "edge with id '{$id}' not exist", |
| 87 | 87 | RepositoryException::EDGE_NOT_FOUND |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | ?FilterConditionInterface $condition |
| 134 | 134 | ): TraverseStepIteratorInterface { |
| 135 | 135 | $result = []; |
| 136 | - foreach($source[$vertex->getId()] ?? [] as $edgeId => [$edgeType, $targetId]) { |
|
| 136 | + foreach ($source[$vertex->getId()] ?? [] as $edgeId => [$edgeType, $targetId]) { |
|
| 137 | 137 | $edge = $this->getEdgeById($edgeId); |
| 138 | - if($this->isSuitableEdge($edge, $condition)) { |
|
| 138 | + if ($this->isSuitableEdge($edge, $condition)) { |
|
| 139 | 139 | $target = $this->getVertexById($targetId); |
| 140 | - if($this->isSuitableVertex($target, $condition)) { |
|
| 140 | + if ($this->isSuitableVertex($target, $condition)) { |
|
| 141 | 141 | $result[] = new TraverseStepItem($edge, $target); |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | $passCondition = $this->getDefaultPassCondition($context); |
| 33 | 33 | |
| 34 | - if($this->needToPreventLoopPass($context)) { |
|
| 34 | + if ($this->needToPreventLoopPass($context)) { |
|
| 35 | 35 | $passCondition = (clone $passCondition)->onlyVertexTypes([]); |
| 36 | - } elseif($this->needToCheckReturnBackPass() && ($prevVertex = $context->getPrevVertex()) !== null) { |
|
| 36 | + } elseif ($this->needToCheckReturnBackPass() && ($prevVertex = $context->getPrevVertex()) !== null) { |
|
| 37 | 37 | $passCondition = (clone $passCondition)->excludeVertexIds([$prevVertex->getId()]); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $handleCondition = $this->getDefaultHandleCondition($context); |
| 50 | 50 | |
| 51 | - if($this->needToPreventLoopHandle($context) || $this->needToPreventRepeatHandle($context)) { |
|
| 51 | + if ($this->needToPreventLoopHandle($context) || $this->needToPreventRepeatHandle($context)) { |
|
| 52 | 52 | $handleCondition = (clone $handleCondition)->onlyVertexTypes([]); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -87,20 +87,20 @@ discard block |
||
| 87 | 87 | $globalPassedVertexesMap = $startContext->getGlobalPassedVertexesMap(); |
| 88 | 88 | $contexts = $this->createContextCollection($traverseMode, $startContext); |
| 89 | 89 | |
| 90 | - while(count($contexts)) { |
|
| 90 | + while (count($contexts)) { |
|
| 91 | 91 | /** @var TraverseContextInterface $currentContext */ |
| 92 | 92 | $currentContext = $contexts->pop(); |
| 93 | 93 | $currentVertex = $currentContext->getVertex(); |
| 94 | 94 | |
| 95 | 95 | $customPassCondition = null; |
| 96 | - if($filter->matchesHandleCondition($currentContext)) { |
|
| 96 | + if ($filter->matchesHandleCondition($currentContext)) { |
|
| 97 | 97 | $cmd = (yield $currentContext); |
| 98 | 98 | |
| 99 | - if($cmd instanceof FilterConditionInterface) { |
|
| 99 | + if ($cmd instanceof FilterConditionInterface) { |
|
| 100 | 100 | $customPassCondition = $cmd; |
| 101 | 101 | yield $currentContext; |
| 102 | 102 | } else { |
| 103 | - switch($cmd) { |
|
| 103 | + switch ($cmd) { |
|
| 104 | 104 | case static::STOP_BRANCH: |
| 105 | 105 | yield $currentContext; |
| 106 | 106 | continue 2; |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | $nextVertexes = $this->getNextVertexes($currentVertex, $customPassCondition); |
| 119 | 119 | |
| 120 | 120 | $i = 0; |
| 121 | - foreach($nextVertexes as $edge => $vertex) { |
|
| 121 | + foreach ($nextVertexes as $edge => $vertex) { |
|
| 122 | 122 | $currentBranchContext = $currentContext->getBranchContext(); |
| 123 | - if(count($nextVertexes) > 1 && $i > 0) { |
|
| 123 | + if (count($nextVertexes) > 1 && $i > 0) { |
|
| 124 | 124 | $nextBranchContext = $this->createBranchContext( |
| 125 | 125 | ++$lastBranchIndex, |
| 126 | 126 | $currentBranchContext->getIndex(), |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | int $traverseMode, |
| 170 | 170 | TraverseContextInterface $startContext |
| 171 | 171 | ): Collection { |
| 172 | - if($traverseMode === self::MODE_WIDE) { |
|
| 172 | + if ($traverseMode === self::MODE_WIDE) { |
|
| 173 | 173 | $contexts = new Queue([$startContext]); |
| 174 | 174 | } else { |
| 175 | 175 | $contexts = new Stack([$startContext]); |