1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Neomerx\JsonApi\Parser\RelationshipData; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Copyright 2015-2019 [email protected] |
7
|
|
|
* |
8
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
9
|
|
|
* you may not use this file except in compliance with the License. |
10
|
|
|
* You may obtain a copy of the License at |
11
|
|
|
* |
12
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
* |
14
|
|
|
* Unless required by applicable law or agreed to in writing, software |
15
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
16
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17
|
|
|
* See the License for the specific language governing permissions and |
18
|
|
|
* limitations under the License. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
use Neomerx\JsonApi\Contracts\Parser\IdentifierInterface; |
22
|
|
|
use Neomerx\JsonApi\Contracts\Parser\RelationshipDataInterface; |
23
|
|
|
use Neomerx\JsonApi\Contracts\Parser\ResourceInterface; |
24
|
|
|
use Neomerx\JsonApi\Exceptions\LogicException; |
25
|
|
|
use function Neomerx\JsonApi\I18n\format as _; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @package Neomerx\JsonApi |
29
|
|
|
*/ |
30
|
|
|
class RelationshipDataIsNull implements RelationshipDataInterface |
31
|
|
|
{ |
32
|
|
|
/** @var string */ |
33
|
|
|
public const MSG_INVALID_OPERATION = 'Invalid operation.'; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @inheritdoc |
37
|
|
|
*/ |
38
|
5 |
|
public function isCollection(): bool |
39
|
|
|
{ |
40
|
5 |
|
return false; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @inheritdoc |
45
|
|
|
*/ |
46
|
5 |
|
public function isNull(): bool |
47
|
|
|
{ |
48
|
5 |
|
return true; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @inheritdoc |
53
|
|
|
*/ |
54
|
5 |
|
public function isResource(): bool |
55
|
|
|
{ |
56
|
5 |
|
return false; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @inheritdoc |
61
|
|
|
*/ |
62
|
5 |
|
public function isIdentifier(): bool |
63
|
|
|
{ |
64
|
5 |
|
return false; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @inheritdoc |
69
|
|
|
*/ |
70
|
|
|
public function getIdentifier(): IdentifierInterface |
71
|
|
|
{ |
72
|
|
|
throw new LogicException(_(static::MSG_INVALID_OPERATION)); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @inheritdoc |
77
|
|
|
*/ |
78
|
|
|
public function getIdentifiers(): iterable |
79
|
|
|
{ |
80
|
|
|
throw new LogicException(_(static::MSG_INVALID_OPERATION)); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @inheritdoc |
85
|
|
|
*/ |
86
|
|
|
public function getResource(): ResourceInterface |
87
|
|
|
{ |
88
|
|
|
throw new LogicException(_(static::MSG_INVALID_OPERATION)); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @inheritdoc |
93
|
|
|
*/ |
94
|
|
|
public function getResources(): iterable |
95
|
|
|
{ |
96
|
|
|
throw new LogicException(_(static::MSG_INVALID_OPERATION)); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|