ComparisonExpression::dump()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the tmilos/scim-filter-parser package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Tmilos\ScimFilterParser\Ast;
13
14
class ComparisonExpression extends Factor
15
{
16
    /** @var AttributePath */
17
    public $attributePath;
18
19
    /** @var string */
20
    public $operator;
21
22
    /** @var mixed */
23
    public $compareValue;
24
25
    /**
26
     * @param AttributePath $attributePath
27
     * @param string        $operator
28
     * @param mixed         $compareValue
29
     */
30
    public function __construct(AttributePath $attributePath, $operator, $compareValue = null)
31
    {
32
        $this->attributePath = $attributePath;
33
        $this->operator = $operator;
34
        $this->compareValue = $compareValue;
35
    }
36
37
    public function __toString()
38
    {
39
        if ($this->operator === 'pr') {
40
            return sprintf('%s %s', $this->attributePath, $this->operator);
41
        } else {
42
            return sprintf('%s %s %s', $this->attributePath, $this->operator, $this->compareValue instanceof \DateTime ? $this->compareValue->format('Y-m-d\TH:i:s\Z') : $this->compareValue);
43
        }
44
    }
45
46
    public function dump()
47
    {
48
        return [
49
            'ComparisonExpression' => (string) $this,
50
        ];
51
    }
52
}
53