1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Stratadox\Hydration\Proxying; |
||
6 | |||
7 | use function is_null; |
||
8 | use Stratadox\Hydration\LoadsProxiedObjects; |
||
9 | use Stratadox\Hydration\Proxy; |
||
10 | |||
11 | /** |
||
12 | * Lazily loads proxy targets. |
||
13 | * |
||
14 | * @author Stratadox |
||
15 | * @package Stratadox/Hydrate |
||
16 | */ |
||
17 | trait Proxying |
||
18 | { |
||
19 | /** @var LoadsProxiedObjects */ |
||
20 | private $loader; |
||
21 | |||
22 | /** @var object|null */ |
||
23 | private $instance; |
||
24 | |||
25 | /** @return self */ |
||
26 | public function __load() |
||
27 | { |
||
28 | if (is_null($this->instance)) { |
||
29 | /** @var Proxy $this */ |
||
30 | $this->instance = $this->loader->loadTheInstance(); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
31 | } |
||
32 | return $this->instance; |
||
33 | } |
||
34 | } |
||
35 |