HasTypeFunctions   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 53
ccs 10
cts 10
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A toString() 0 4 1
A toBool() 0 4 1
A toNumber() 0 4 1
A toList() 0 4 1
A toArray() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\FluentAQL\AQL;
6
7
use LaravelFreelancerNL\FluentAQL\Expressions\FunctionExpression;
8
9
/**
10
 * Type AQL functions.
11
 *
12
 * @see https://www.arangodb.com/docs/stable/aql/functions-type-cast.html
13
 */
14
trait HasTypeFunctions
15
{
16
    /**
17
     * Take an input value of any type and convert it into an array value.
18
     *
19
     * @link https://www.arangodb.com/docs/stable/aql/functions-type-cast.html#to_array
20
     */
21 2
    public function toArray(
22
        mixed $value,
23
    ): FunctionExpression {
24 2
        return new FunctionExpression('TO_ARRAY', [$value]);
25
    }
26
27
    /**
28
     * Take an input value of any type and convert it into the appropriate boolean value.
29
     *
30
     * @link https://www.arangodb.com/docs/stable/aql/functions-type-cast.html#to_bool
31
     */
32 1
    public function toBool(
33
        mixed $value,
34
    ): FunctionExpression {
35 1
        return new FunctionExpression('TO_BOOL', [$value]);
36
    }
37
38
    /**
39
     * Alias for toArray
40
     */
41 1
    public function toList(
42
        mixed $value,
43
    ): FunctionExpression {
44 1
        return $this->toArray($value);
45
    }
46
47
    /**
48
     * Take an input value of any type and convert it into a numeric value.
49
     *
50
     * @link https://www.arangodb.com/docs/stable/aql/functions-type-cast.html#to_number
51
     */
52 1
    public function toNumber(
53
        mixed $value,
54
    ): FunctionExpression {
55 1
        return new FunctionExpression('TO_NUMBER', [$value]);
56
    }
57
58
    /**
59
     * Take an input value of any type and convert it into a string value.
60
     *
61
     * @link https://www.arangodb.com/docs/stable/aql/functions-type-cast.html#to_string
62
     */
63 1
    public function toString(
64
        mixed $value,
65
    ): FunctionExpression {
66 1
        return new FunctionExpression('TO_STRING', [$value]);
67
    }
68
}
69