Passed
Push — next ( ee2197...d54041 )
by Bas
02:37
created

src/AQL/HasGraphClauses.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\FluentAQL\AQL;
6
7
use LaravelFreelancerNL\FluentAQL\Clauses\EdgeCollectionsClause;
8
use LaravelFreelancerNL\FluentAQL\Clauses\GraphClause;
9
use LaravelFreelancerNL\FluentAQL\Clauses\PruneClause;
10
use LaravelFreelancerNL\FluentAQL\Clauses\TraverseClause;
11
use LaravelFreelancerNL\FluentAQL\Clauses\TraverseKPathsClause;
12
use LaravelFreelancerNL\FluentAQL\Clauses\TraverseKShortestPathsClause;
13
use LaravelFreelancerNL\FluentAQL\Clauses\TraverseShortestPathClause;
14
use LaravelFreelancerNL\FluentAQL\Clauses\WithClause;
15
use LaravelFreelancerNL\FluentAQL\Expressions\Expression;
16
use LaravelFreelancerNL\FluentAQL\QueryBuilder;
17
18
/**
19
 * Trait hasGraphClauses
20
 * API calls to add clause commands to the builder.
21
 */
22
trait HasGraphClauses
23
{
24
    abstract public function addCommand($command);
25
26
    /**
27
     * Start a query with 'WITH' to prevent graph traversal deadlocks.
28
     * This is required in clusters.
29
     *
30
     * @link https://www.arangodb.com/docs/stable/aql/operations-with.html
31
     */
32 2
    public function with(): self
33
    {
34
        /** @var array<array-key, Expression|string> $arguments */
35 2
        $arguments = func_get_args();
36 2
        $this->addCommand(new WithClause($arguments));
37
38 2
        return $this;
39
    }
40
41
    /**
42
     * Traverse a graph
43
     * Must be preceded by a FOR clause.
44
     *
45
     * @link https://www.arangodb.com/docs/stable/aql/graphs-traversals.html
46
     *
47
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
48
     */
49 2
    public function traverse(
50
        string|QueryBuilder|Expression $fromVertex,
51
        string|QueryBuilder|Expression $inDirection = 'outbound'
52
    ): self {
53 2
        $this->addCommand(new TraverseClause($fromVertex, $inDirection));
54
55 2
        return $this;
56
    }
57
58
    /**
59
     * Shortest path alias for traverse.
60
     *
61
     * @link arangodb.com/docs/stable/aql/graphs-shortest-path.html
62
     */
63 1
    public function shortestPath(
64
        string|QueryBuilder|Expression $fromVertex,
65
        string|QueryBuilder|Expression $inDirection,
66
        string|QueryBuilder|Expression $toVertex
67
    ): self {
68 1
        $this->addCommand(new TraverseShortestPathClause($fromVertex, $inDirection, $toVertex));
69
70 1
        return $this;
71
    }
72
73
    /**
74
     * K Shortest Paths alias for traverse.
75
     *
76
     * @link https://www.arangodb.com/docs/stable/aql/graphs-kshortest-paths.html
77
     */
78 1
    public function kShortestPaths(
79
        string|QueryBuilder|Expression $fromVertex,
80
        string|QueryBuilder|Expression $inDirection,
81
        string|QueryBuilder|Expression $toVertex
82
    ): self {
83 1
        $this->addCommand(new TraverseKShortestPathsClause($fromVertex, $inDirection, $toVertex));
84
85 1
        return $this;
86
    }
87
88
    /**
89
     * K Paths alias for traverse.
90
     *
91
     * @link https://www.arangodb.com/docs/stable/aql/graphs-k-paths.html
92
     */
93 1
    public function kPaths(
94
        string|QueryBuilder|Expression $fromVertex,
95
        string|QueryBuilder|Expression $inDirection,
96
        string|QueryBuilder|Expression $toVertex
97
    ): self {
98 1
        $this->addCommand(new TraverseKPathsClause($fromVertex, $inDirection, $toVertex));
99
100 1
        return $this;
101
    }
102
103
    /**
104
     * Named Graph clause
105
     * Only usable after traverse/shortestPath/kShortestPaths Clauses.
106
     *
107
     * @link https://www.arangodb.com/docs/stable/aql/graphs-traversals.html
108
     */
109 1
    public function graph(
110
        string|QueryBuilder|Expression $graphName
111
    ): self {
112 1
        $this->addCommand(new GraphClause($graphName));
113
114 1
        return $this;
115
    }
116
117
    /**
118
     * EdgeCollections Clause for unnamed graphs
119
     * Generates a list of edge collections to traverse through.
120
     * Only usable after traverse/shortestPath/kShortestPaths Clauses.
121
     *
122
     * @link https://www.arangodb.com/docs/stable/aql/graphs-traversals.html
123
     */
124 3
    public function edgeCollections(): self
125
    {
126
        /** @var array<array<string>|Expression> $edgeCollections */
127 3
        $edgeCollections = func_get_args();
128
129 3
        $this->addCommand(new EdgeCollectionsClause($edgeCollections));
130
131 3
        return $this;
132
    }
133
134
    /**
135
     * Prune a graph traversal.
136
     *
137
     * @link https://www.arangodb.com/docs/stable/aql/graphs-traversals.html#pruning
138
     *
139
     * @param object|array<mixed>|string|int|float|bool|null $leftOperand
140
     * @param object|array<mixed>|string|int|float|bool|null $rightOperand
141
     */
142 2
    public function prune(
143
        object|array|string|int|float|bool|null $leftOperand,
0 ignored issues
show
The type LaravelFreelancerNL\FluentAQL\AQL\null was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
144
        string|QueryBuilder|Expression $comparisonOperator = null,
145
        object|array|string|int|float|bool|null $rightOperand = null,
146
        string|QueryBuilder|Expression $logicalOperator = null
147
    ): self {
148 2
        $predicates = $leftOperand;
149 2
        if (! is_array($predicates)) {
150 1
            $predicates = [[$leftOperand, $comparisonOperator, $rightOperand, $logicalOperator]];
151
        }
152
153 2
        $this->addCommand(new PruneClause($predicates));
154
155 2
        return $this;
156
    }
157
}
158