|
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 Path extends Node |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var AttributePath */ |
|
17
|
|
|
private $attributePath; |
|
18
|
|
|
|
|
19
|
|
|
/** @var ValuePath */ |
|
20
|
|
|
private $valuePath; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param AttributePath $attributePath |
|
24
|
|
|
* |
|
25
|
|
|
* @return Path |
|
26
|
|
|
*/ |
|
27
|
|
|
public static function fromAttributePath(AttributePath $attributePath) |
|
28
|
|
|
{ |
|
29
|
|
|
return new static($attributePath, null); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param ValuePath $valuePath |
|
34
|
|
|
* @param AttributePath|null $attributePath |
|
35
|
|
|
* |
|
36
|
|
|
* @return Path |
|
37
|
|
|
*/ |
|
38
|
|
|
public static function fromValuePath(ValuePath $valuePath, AttributePath $attributePath = null) |
|
39
|
|
|
{ |
|
40
|
|
|
return new static($attributePath, $valuePath); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param AttributePath $attributePath |
|
45
|
|
|
* @param ValuePath $valuePath |
|
46
|
|
|
*/ |
|
47
|
|
|
private function __construct(AttributePath $attributePath = null, ValuePath $valuePath = null) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->attributePath = $attributePath; |
|
50
|
|
|
$this->valuePath = $valuePath; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function dump() |
|
54
|
|
|
{ |
|
55
|
|
|
if (!$this->valuePath) { |
|
56
|
|
|
return [ |
|
57
|
|
|
'Path' => $this->attributePath->dump(), |
|
58
|
|
|
]; |
|
59
|
|
|
} elseif (!$this->attributePath) { |
|
60
|
|
|
return [ |
|
61
|
|
|
'Path' => $this->valuePath->dump(), |
|
62
|
|
|
]; |
|
63
|
|
|
} else { |
|
64
|
|
|
return array_merge($this->valuePath->dump(), $this->attributePath->dump()); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return AttributePath |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getAttributePath() |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->attributePath; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @return ValuePath |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getValuePath() |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->valuePath; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|