Passed
Branch next (ee2197)
by Bas
02:37
created

HasTypeFunctions::toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
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