@@ -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 |
@@ -15,8 +15,8 @@ |
||
15 | 15 | public static function combine(EdgeVertexPairsIteratorInterface ...$iterators): EdgeVertexPairsIteratorInterface |
16 | 16 | { |
17 | 17 | $source = []; |
18 | - foreach($iterators as $iterator) { |
|
19 | - foreach($iterator as $edge => $vertex) { |
|
18 | + foreach ($iterators as $iterator) { |
|
19 | + foreach ($iterator as $edge => $vertex) { |
|
20 | 20 | $source[] = new EdgeVertexPair($edge, $vertex); |
21 | 21 | } |
22 | 22 | } |
@@ -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 | ): EdgeVertexPairsIteratorInterface { |
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 EdgeVertexPair($edge, $target); |
142 | 142 | } |
143 | 143 | } |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | { |
18 | 18 | $branchMap = []; |
19 | 19 | /** @var TraverseContextInterface $context */ |
20 | - foreach($contexts as $context) { |
|
21 | - if(is_callable($callback)) { |
|
20 | + foreach ($contexts as $context) { |
|
21 | + if (is_callable($callback)) { |
|
22 | 22 | $callback($context, $contexts); |
23 | 23 | } |
24 | 24 | |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | $parentBranchIndex = $context->getBranchContext()->getParentIndex(); |
28 | 28 | $vertex = $context->getVertex(); |
29 | 29 | |
30 | - if(!isset($branchMap[$branchIndex])) { |
|
31 | - if(isset($branchMap[$parentBranchIndex])) { |
|
30 | + if (!isset($branchMap[$branchIndex])) { |
|
31 | + if (isset($branchMap[$parentBranchIndex])) { |
|
32 | 32 | $parentBranch = $branchMap[$parentBranchIndex]; |
33 | 33 | $key = array_search($branchContext->getStart(), $parentBranch); |
34 | 34 | $branchMap[$branchIndex] = array_slice($parentBranch, 0, $key+1); |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | { |
48 | 48 | $passCondition = $this->passCondition; |
49 | 49 | |
50 | - if( |
|
50 | + if ( |
|
51 | 51 | $this->config->isOn(FilterConfig::PREVENT_LOOP_PASS) |
52 | 52 | && $context->isLoop() |
53 | 53 | ) { |
54 | 54 | $passCondition = (clone $this->passCondition)->onlyVertexTypes([]); |
55 | - } elseif( |
|
55 | + } elseif ( |
|
56 | 56 | $this->config->isOn(FilterConfig::PREVENT_RETURN_BACK) |
57 | 57 | && ($prevVertex = $context->getPrevVertex()) !== null |
58 | 58 | ) { |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $handleCondition = $this->handleCondition; |
72 | 72 | $globalPassed = $context->getGlobalPassedVertexesMap(); |
73 | 73 | |
74 | - if( |
|
74 | + if ( |
|
75 | 75 | ( |
76 | 76 | $this->config->isOn(FilterConfig::PREVENT_LOOP_HANDLE) |
77 | 77 | && $context->isLoop() |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | $globalPassedVertexesMap = $startContext->getGlobalPassedVertexesMap(); |
61 | 61 | |
62 | 62 | $contexts = new Queue([$startContext]); |
63 | - while(count($contexts)) { |
|
63 | + while (count($contexts)) { |
|
64 | 64 | /** @var TraverseContextInterface $currentContext */ |
65 | 65 | $currentContext = $contexts->pop(); |
66 | 66 | $currentVertex = $currentContext->getVertex(); |
67 | 67 | $currentEdge = $currentContext->getEdge(); |
68 | 68 | |
69 | - if($filter->getHandleCondition($currentContext)->isSuitableVertex($currentContext->getVertex())) { |
|
69 | + if ($filter->getHandleCondition($currentContext)->isSuitableVertex($currentContext->getVertex())) { |
|
70 | 70 | $cmd = (yield $currentEdge => $currentContext); |
71 | - switch($cmd) { |
|
71 | + switch ($cmd) { |
|
72 | 72 | case static::STOP_BRANCH: |
73 | 73 | yield $currentEdge => $currentContext; |
74 | 74 | continue 2; |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | |
84 | 84 | $nextVertexes = $this->getNextVertexes($currentVertex, $filter->getPassCondition($currentContext)); |
85 | 85 | $i = 0; |
86 | - foreach($nextVertexes as $edge => $vertex) { |
|
86 | + foreach ($nextVertexes as $edge => $vertex) { |
|
87 | 87 | $currentBranchContext = $currentContext->getBranchContext(); |
88 | - if(count($nextVertexes) > 1 && $i > 0) { |
|
88 | + if (count($nextVertexes) > 1 && $i > 0) { |
|
89 | 89 | $nextBranchContext = $this->createBranchContext( |
90 | 90 | ++$lastBranchIndex, |
91 | 91 | $currentBranchContext->getIndex(), |