1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace POData\UriProcessor\ResourcePathProcessor\SegmentParser; |
6
|
|
|
|
7
|
|
|
use MyCLabs\Enum\Enum; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @method static TargetKind NOTHING() |
11
|
|
|
* @method static TargetKind SERVICE_DIRECTORY() |
12
|
|
|
* @method static TargetKind RESOURCE() |
13
|
|
|
* @method static TargetKind COMPLEX_OBJECT() |
14
|
|
|
* @method static TargetKind PRIMITIVE() |
15
|
|
|
* @method static TargetKind PRIMITIVE_VALUE() |
16
|
|
|
* @method static TargetKind METADATA() |
17
|
|
|
* @method static TargetKind VOID_SERVICE_OPERATION() |
18
|
|
|
* @method static TargetKind BATCH() |
19
|
|
|
* @method static TargetKind LINK() |
20
|
|
|
* @method static TargetKind MEDIA_RESOURCE() |
21
|
|
|
* @method static TargetKind BAG() |
22
|
|
|
* @method static TargetKind SINGLETON() |
23
|
|
|
*/ |
24
|
|
|
class TargetKind extends Enum |
25
|
|
|
{ |
26
|
|
|
protected const TERMINAL_VALUES = [6 => true, 7 => true, 9 => true, 11 => true, 12 => true]; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Nothing specific is being requested. |
30
|
|
|
* e.g. http://localhost. |
31
|
|
|
*/ |
32
|
|
|
protected const NOTHING = 1; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* A top-level directory of service capabilities. |
36
|
|
|
* e.g. http://localhost/myservice.svc. |
37
|
|
|
*/ |
38
|
|
|
protected const SERVICE_DIRECTORY = 2; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Entity Resource is requested - it can be a collection or a single value. |
42
|
|
|
* e.g. http://localhost/myservice.svc/Customers |
43
|
|
|
* http://localhost/myservice.svc/Customers('ALFKI')/Orders(123). |
44
|
|
|
*/ |
45
|
|
|
protected const RESOURCE = 3; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* A single complex value is requested (eg: an Address). |
49
|
|
|
* e.g. http://localhost/myservice.svc/Address. |
50
|
|
|
*/ |
51
|
|
|
protected const COMPLEX_OBJECT = 4; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* A single value is requested (eg: a Picture property). |
55
|
|
|
* e.g. http://localhost/myservice.svc/Customers('ALFKI')/CustomerName |
56
|
|
|
* http://localhost/myservice.svc/Address/LineNumber. |
57
|
|
|
*/ |
58
|
|
|
protected const PRIMITIVE = 5; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* A single value is requested (eg: the raw stream of a Picture). |
62
|
|
|
* e.g. http://localhost/myservice.svc/Customers('ALFKI')/CustomerName/$value |
63
|
|
|
* http://localhost/myservice.svc/Customers/$count. |
64
|
|
|
*/ |
65
|
|
|
protected const PRIMITIVE_VALUE = 6; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* System metadata. |
69
|
|
|
* e.g. http://localhost/myservice.svc/$metadata. |
70
|
|
|
*/ |
71
|
|
|
protected const METADATA = 7; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* A data-service-defined operation that doesn't return anything. |
75
|
|
|
*/ |
76
|
|
|
protected const VOID_SERVICE_OPERATION = 8; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* The request is a batch request. |
80
|
|
|
* e.g. http://localhost/myservice.svc/$batch. |
81
|
|
|
*/ |
82
|
|
|
protected const BATCH = 9; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* The request is a link operation - bind or unbind or simple get |
86
|
|
|
* e.g. http://localhost/myservice.svc/Customers('ALFKI')/$links/Orders. |
87
|
|
|
*/ |
88
|
|
|
protected const LINK = 10; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* A stream property value is requested. |
92
|
|
|
* e.g. http://localhost/myservice.svc/Albums('trip')/Photos('123')/$value |
93
|
|
|
* e.g. http://localhost/myservice.svc/Albums('trip')/Photos('123')/ThumNail64x64/$value. |
94
|
|
|
*/ |
95
|
|
|
protected const MEDIA_RESOURCE = 11; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* A single bag of primitive or complex values is requested |
99
|
|
|
* e.g. http://localhost/myservice.svc/Customers('ALFKI')/EMails. |
100
|
|
|
*/ |
101
|
|
|
protected const BAG = 12; |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* A singleton (parameter-less function wrapper). |
105
|
|
|
*/ |
106
|
|
|
protected const SINGLETON = 13; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Is this segment a terminal segment - nothing else can be added after it? |
110
|
|
|
* |
111
|
|
|
* @return bool |
112
|
|
|
*/ |
113
|
|
|
public function isTerminal(): bool |
114
|
|
|
{ |
115
|
|
|
return array_key_exists($this->getValue(), self::TERMINAL_VALUES); |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|