Passed
Pull Request — master (#13)
by Bas
03:44 queued 01:39
created

HasOperatorExpressions::if()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace LaravelFreelancerNL\FluentAQL\AQL;
4
5
use LaravelFreelancerNL\FluentAQL\Expressions\ArithmeticExpression;
6
use LaravelFreelancerNL\FluentAQL\Expressions\TernaryExpression;
7
8
/**
9
 * Trait hasFunctions.
10
 *
11
 * AQL Function API calls.
12
 */
13
trait HasOperatorExpressions
14
{
15
    /**
16
     * Evaluate a condition
17
     *
18
     * @link https://www.arangodb.com/docs/stable/aql/operators.html#ternary-operator
19
     *
20
     * @param $conditions
21
     * @param $then
22
     * @param $else
23
     * @return TernaryExpression
24
     */
25
    public function if($conditions, $then, $else)
26
    {
27
        return new TernaryExpression($conditions, $then, $else);
28
    }
29
30
    /**
31
     * Perform an arithmetic operation on two numbers
32
     *
33
     * @link https://www.arangodb.com/docs/stable/aql/operators.html#arithmetic-operators
34
     *
35
     * @param $leftOperand
36
     * @param $operator
37
     * @param $rightOperand
38
     * @return ArithmeticExpression
39
     */
40
    public function calc($leftOperand, $operator, $rightOperand)
41
    {
42
        return new ArithmeticExpression($leftOperand, $operator, $rightOperand);
43
    }
44
}
45