@@ -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 | |
@@ -50,11 +50,11 @@ |
||
| 50 | 50 | |
| 51 | 51 | public function isSuitableEdge(EdgeInterface $edge): bool |
| 52 | 52 | { |
| 53 | - if($this->edgeTypesOnly !== null && !in_array($edge->getType(), $this->edgeTypesOnly)) { |
|
| 53 | + if ($this->edgeTypesOnly !== null && !in_array($edge->getType(), $this->edgeTypesOnly)) { |
|
| 54 | 54 | return false; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if(in_array($edge->getType(), $this->edgeTypesExclude)) { |
|
| 57 | + if (in_array($edge->getType(), $this->edgeTypesExclude)) { |
|
| 58 | 58 | return false; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -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 | } |
@@ -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); |
@@ -85,20 +85,20 @@ discard block |
||
| 85 | 85 | $lastBranchIndex = $startContext->getBranchContext()->getIndex(); |
| 86 | 86 | $globalPassedVertexesMap = $startContext->getGlobalPassedVertexesMap(); |
| 87 | 87 | |
| 88 | - if($traverseMode === self::MODE_WIDE) { |
|
| 88 | + if ($traverseMode === self::MODE_WIDE) { |
|
| 89 | 89 | $contexts = new Queue([$startContext]); |
| 90 | 90 | } else { |
| 91 | 91 | $contexts = new Stack([$startContext]); |
| 92 | 92 | } |
| 93 | - while(count($contexts)) { |
|
| 93 | + while (count($contexts)) { |
|
| 94 | 94 | /** @var TraverseContextInterface $currentContext */ |
| 95 | 95 | $currentContext = $contexts->pop(); |
| 96 | 96 | $currentVertex = $currentContext->getVertex(); |
| 97 | 97 | $currentEdge = $currentContext->getEdge(); |
| 98 | 98 | |
| 99 | - if($filter->getHandleCondition($currentContext)->isSuitableVertex($currentContext->getVertex())) { |
|
| 99 | + if ($filter->getHandleCondition($currentContext)->isSuitableVertex($currentContext->getVertex())) { |
|
| 100 | 100 | $cmd = (yield $currentEdge => $currentContext); |
| 101 | - switch($cmd) { |
|
| 101 | + switch ($cmd) { |
|
| 102 | 102 | case static::STOP_BRANCH: |
| 103 | 103 | yield $currentEdge => $currentContext; |
| 104 | 104 | continue 2; |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $nextVertexes = $this->getNextVertexes($currentVertex, $filter->getPassCondition($currentContext)); |
| 115 | 115 | $i = 0; |
| 116 | - foreach($nextVertexes as $edge => $vertex) { |
|
| 116 | + foreach ($nextVertexes as $edge => $vertex) { |
|
| 117 | 117 | $currentBranchContext = $currentContext->getBranchContext(); |
| 118 | - if(count($nextVertexes) > 1 && $i > 0) { |
|
| 118 | + if (count($nextVertexes) > 1 && $i > 0) { |
|
| 119 | 119 | $nextBranchContext = $this->createBranchContext( |
| 120 | 120 | ++$lastBranchIndex, |
| 121 | 121 | $currentBranchContext->getIndex(), |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $passCondition = $this->passCondition; |
| 54 | 54 | |
| 55 | - if( |
|
| 55 | + if ( |
|
| 56 | 56 | $this->config->has(FilterConfig::PREVENT_LOOP_PASS) |
| 57 | 57 | && $context->isLoop() |
| 58 | 58 | ) { |
| 59 | 59 | $passCondition = (clone $this->passCondition)->onlyVertexTypes([]); |
| 60 | - } elseif( |
|
| 60 | + } elseif ( |
|
| 61 | 61 | $this->config->has(FilterConfig::PREVENT_RETURN_BACK) |
| 62 | 62 | && ($prevVertex = $context->getPrevVertex()) !== null |
| 63 | 63 | ) { |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $handleCondition = $this->handleCondition; |
| 77 | 77 | $globalPassed = $context->getGlobalPassedVertexesMap(); |
| 78 | 78 | |
| 79 | - if( |
|
| 79 | + if ( |
|
| 80 | 80 | ( |
| 81 | 81 | $this->config->has(FilterConfig::PREVENT_LOOP_HANDLE) |
| 82 | 82 | && $context->isLoop() |