Total Complexity | 9 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 88.24% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | final class Promise implements ReferenceInterface |
||
10 | { |
||
11 | 184 | public function __construct( |
|
12 | private ActiveRelationInterface $relation, |
||
13 | private ReferenceInterface $origin |
||
14 | ) { |
||
15 | } |
||
16 | |||
17 | 40 | public function fetch(): object|iterable|null |
|
18 | { |
||
19 | 40 | if (!$this->origin->hasValue()) { |
|
20 | 40 | $this->resolve(); |
|
21 | } |
||
22 | 40 | return $this->relation->collect($this->origin->getValue()); |
|
23 | } |
||
24 | |||
25 | 48 | public function resolve(): void |
|
26 | { |
||
27 | 48 | $this->relation->resolve($this->origin, true); |
|
28 | } |
||
29 | |||
30 | 56 | public function getRole(): string |
|
33 | } |
||
34 | |||
35 | 88 | public function getScope(): array |
|
36 | { |
||
37 | 88 | return $this->origin->getScope(); |
|
38 | } |
||
39 | |||
40 | 80 | public function hasValue(): bool |
|
41 | { |
||
42 | 80 | return $this->origin->hasValue(); |
|
43 | } |
||
44 | |||
45 | public function setValue(mixed $value): void |
||
46 | { |
||
47 | $this->origin->setValue($value); |
||
48 | } |
||
49 | |||
50 | 24 | public function getValue(): mixed |
|
53 | } |
||
54 | } |
||
55 |