HasOperatorExpressions   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 28
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A calc() 0 6 1
A if() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\FluentAQL\AQL;
6
7
use LaravelFreelancerNL\FluentAQL\Expressions\ArithmeticExpression;
8
use LaravelFreelancerNL\FluentAQL\Expressions\Expression;
9
use LaravelFreelancerNL\FluentAQL\Expressions\PredicateExpression;
10
use LaravelFreelancerNL\FluentAQL\Expressions\TernaryExpression;
11
use LaravelFreelancerNL\FluentAQL\QueryBuilder;
12
13
/**
14
 * Trait hasFunctions.
15
 *
16
 * AQL Function API calls.
17
 */
18
trait HasOperatorExpressions
19
{
20
    /**
21
     * Evaluate a condition
22
     *
23
     * @link https://www.arangodb.com/docs/stable/aql/operators.html#ternary-operator
24
     *
25
     * @param array<mixed>|PredicateExpression $conditions
26
     */
27 1
    public function if(
28
        array|PredicateExpression $conditions,
29
        mixed $then,
30
        mixed $else = null
31
    ): TernaryExpression {
32 1
        return new TernaryExpression($conditions, $then, $else);
33
    }
34
35
    /**
36
     * Perform an arithmetic operation on two numbers
37
     *
38
     * @link https://www.arangodb.com/docs/stable/aql/operators.html#arithmetic-operators
39
     */
40 3
    public function calc(
41
        int|float|null|Expression|QueryBuilder $leftOperand,
42
        string $operator,
43
        int|float|null|Expression|QueryBuilder $rightOperand
44
    ): ArithmeticExpression {
45 3
        return new ArithmeticExpression($leftOperand, $operator, $rightOperand);
46
    }
47
}
48