@@ -53,25 +53,46 @@ public function isEmpty(): bool
53
53
54
54
public function getResource (): ResourceInterface
55
55
{
56
- return $ this ->returnDataIfTrue ($ this ->isResource (), 'Data is not Resource ' );
56
+ $ data = $ this ->data ;
57
+ if (true !== $ this ->isResource ()) {
58
+ throw new DomainException ('Data is not Resource ' );
59
+ }
60
+ /** @var ResourceInterface $data */
61
+
62
+ return $ data ;
57
63
}
58
64
59
65
public function getResourceCollection (): ResourceCollectionInterface
60
66
{
61
- return $ this ->returnDataIfTrue ($ this ->isResourceCollection (), 'Data is not Resource Collection ' );
67
+ $ data = $ this ->data ;
68
+ if (true !== $ this ->isResourceCollection ()) {
69
+ throw new DomainException ('Data is not Resource Collection ' );
70
+ }
71
+ /** @var ResourceCollectionInterface $data */
72
+
73
+ return $ data ;
62
74
}
63
75
64
76
public function getResourceIdentifier (): ResourceIdentifierInterface
65
77
{
66
- return $ this ->returnDataIfTrue ($ this ->isResourceIdentifier (), 'Data is not Resource Identifier ' );
78
+ $ data = $ this ->data ;
79
+ if (true !== $ this ->isResourceIdentifier ()) {
80
+ throw new DomainException ('Data is not Resource Identifier ' );
81
+ }
82
+ /** @var ResourceIdentifierInterface $data */
83
+
84
+ return $ data ;
67
85
}
68
86
69
87
public function getResourceIdentifierCollection (): ResourceIdentifierCollectionInterface
70
88
{
71
- return $ this ->returnDataIfTrue (
72
- $ this ->isResourceIdentifierCollection (),
73
- 'Data is not Resource Identifier Collection '
74
- );
89
+ $ data = $ this ->data ;
90
+ if (true !== $ this ->isResourceIdentifierCollection ()) {
91
+ throw new DomainException ('Data is not Resource Identifier Collection ' );
92
+ }
93
+ /** @var ResourceIdentifierCollectionInterface $data */
94
+
95
+ return $ data ;
75
96
}
76
97
77
98
/**
@@ -115,16 +136,4 @@ private function makeSureDataIsValid($data): void
115
136
116
137
throw new InvalidArgumentException ('Invalid data provided ' );
117
138
}
118
-
119
- /**
120
- * @return null|ResourceCollection|ResourceIdentifierCollection|ResourceIdentifierInterface|ResourceInterface
121
- */
122
- private function returnDataIfTrue (bool $ condition , string $ errorMessage )
123
- {
124
- if (true !== $ condition ) {
125
- throw new DomainException ($ errorMessage );
126
- }
127
-
128
- return $ this ->data ;
129
- }
130
139
}
0 commit comments