3
3
namespace LaravelFreelancerNL \FluentAQL \AQL ;
4
4
5
5
use LaravelFreelancerNL \FluentAQL \Clauses \EdgeCollectionsClause ;
6
+ use LaravelFreelancerNL \FluentAQL \Clauses \FilterClause ;
6
7
use LaravelFreelancerNL \FluentAQL \Clauses \GraphClause ;
7
8
use LaravelFreelancerNL \FluentAQL \Clauses \PruneClause ;
8
9
use LaravelFreelancerNL \FluentAQL \Clauses \TraverseClause ;
10
+ use LaravelFreelancerNL \FluentAQL \Clauses \TraverseKShortestPathClause ;
11
+ use LaravelFreelancerNL \FluentAQL \Clauses \TraverseShortestPathClause ;
9
12
use LaravelFreelancerNL \FluentAQL \Clauses \WithClause ;
10
13
use LaravelFreelancerNL \FluentAQL \QueryBuilder ;
11
14
@@ -25,13 +28,7 @@ trait HasGraphClauses
25
28
*/
26
29
public function with (): QueryBuilder
27
30
{
28
- $ collections = func_get_args ();
29
- foreach ($ collections as $ key => $ collection ) {
30
- $ this ->registerCollections ($ collection , 'read ' );
31
- $ collections [$ key ] = $ this ->normalizeArgument ($ collection , 'Collection ' );
32
- }
33
-
34
- $ this ->addClause (new WithClause ($ collections ));
31
+ $ this ->addClause (new WithClause (func_get_args ()));
35
32
36
33
return $ this ;
37
34
}
@@ -57,14 +54,7 @@ public function traverse(
57
54
$ toVertex = null ,
58
55
$ kShortestPaths = false
59
56
): QueryBuilder {
60
- $ fromVertex = $ this ->normalizeArgument ($ fromVertex , 'Id ' );
61
- $ inDirection = $ this ->normalizeArgument ($ inDirection , 'Direction ' );
62
-
63
- if ($ toVertex !== null ) {
64
- $ toVertex = $ this ->normalizeArgument ($ toVertex , 'Id ' );
65
- }
66
-
67
- $ this ->addClause (new TraverseClause ($ fromVertex , $ inDirection , $ toVertex , $ kShortestPaths ));
57
+ $ this ->addClause (new TraverseClause ($ fromVertex , $ inDirection , $ toVertex ));
68
58
69
59
return $ this ;
70
60
}
@@ -82,7 +72,7 @@ public function traverse(
82
72
*/
83
73
public function shortestPath ($ fromVertex , $ inDirection , $ toVertex ): QueryBuilder
84
74
{
85
- $ this ->traverse ( $ fromVertex , $ inDirection , $ toVertex );
75
+ $ this ->addClause ( new TraverseShortestPathClause ( $ fromVertex , $ inDirection , $ toVertex) );
86
76
87
77
return $ this ;
88
78
}
@@ -100,7 +90,7 @@ public function shortestPath($fromVertex, $inDirection, $toVertex): QueryBuilder
100
90
*/
101
91
public function kShortestPaths ($ fromVertex , $ inDirection , $ toVertex ): QueryBuilder
102
92
{
103
- $ this ->traverse ( $ fromVertex , $ inDirection , $ toVertex, true );
93
+ $ this ->addClause ( new TraverseKShortestPathClause ( $ fromVertex , $ inDirection , $ toVertex) );
104
94
105
95
return $ this ;
106
96
}
@@ -117,8 +107,6 @@ public function kShortestPaths($fromVertex, $inDirection, $toVertex): QueryBuild
117
107
*/
118
108
public function graph (string $ graphName ): QueryBuilder
119
109
{
120
- $ graphName = $ this ->normalizeArgument ($ graphName , 'Graph ' );
121
-
122
110
$ this ->addClause (new GraphClause ($ graphName ));
123
111
124
112
return $ this ;
@@ -131,28 +119,11 @@ public function graph(string $graphName): QueryBuilder
131
119
*
132
120
* @link https://www.arangodb.com/docs/stable/aql/graphs-traversals.html
133
121
*
134
- * @param string|array $edgeCollection
135
- * @param string|null $direction
136
- *
137
122
* @return QueryBuilder
138
123
*/
139
- public function edgeCollections ($ edgeCollection ): QueryBuilder
124
+ public function edgeCollections (): QueryBuilder
140
125
{
141
- $ collections = [];
142
-
143
- //normalize string|null $edgeCollections and $direction
144
- if (is_string ($ edgeCollection )) {
145
- $ collections [] = $ this ->normalizeEdgeCollections ($ edgeCollection );
146
- }
147
-
148
- if (is_array ($ edgeCollection )) {
149
- //Wandel door de array
150
- $ collections = array_map (function ($ expression ) {
151
- return $ this ->normalizeEdgeCollections ($ expression );
152
- }, $ edgeCollection );
153
- }
154
-
155
- $ this ->addClause (new EdgeCollectionsClause ($ collections ));
126
+ $ this ->addClause (new EdgeCollectionsClause (func_get_args ()));
156
127
157
128
return $ this ;
158
129
}
@@ -162,22 +133,24 @@ public function edgeCollections($edgeCollection): QueryBuilder
162
133
*
163
134
* @link https://www.arangodb.com/docs/stable/aql/graphs-traversals.html#pruning
164
135
*
165
- * @param string $attribute
166
- * @param string $comparisonOperator
167
- * @param mixed $value
168
- * @param string $logicalOperator
136
+ * @param $leftOperand
137
+ * @param string $comparisonOperator
138
+ * @param null $rightOperand
139
+ * @param string $logicalOperator
169
140
*
170
141
* @return QueryBuilder
171
142
*/
172
- public function prune ($ attribute , $ comparisonOperator = '== ' , $ value = null , $ logicalOperator = 'AND ' ): QueryBuilder
173
- {
174
- //create array of predicates if $leftOperand isn't an array already
175
- if (is_string ($ attribute )) {
176
- $ attribute = [[$ attribute , $ comparisonOperator , $ value , $ logicalOperator ]];
143
+ public function prune (
144
+ $ leftOperand ,
145
+ $ comparisonOperator = null ,
146
+ $ rightOperand = null ,
147
+ $ logicalOperator = null
148
+ ): QueryBuilder {
149
+ $ predicates = $ leftOperand ;
150
+ if (is_string ($ comparisonOperator )) {
151
+ $ predicates = [[$ leftOperand , $ comparisonOperator , $ rightOperand , $ logicalOperator ]];
177
152
}
178
153
179
- $ predicates = $ this ->normalizePredicates ($ attribute );
180
-
181
154
$ this ->addClause (new PruneClause ($ predicates ));
182
155
183
156
return $ this ;
0 commit comments