1 | <?php |
||
2 | |||
3 | namespace ByTIC\Models\SmartProperties\Definitions\Definition; |
||
4 | |||
5 | /** |
||
6 | * Trait CanBuild |
||
7 | * @package ByTIC\Models\SmartProperties\Definitions\Traits |
||
8 | */ |
||
9 | trait CanBuild |
||
10 | { |
||
11 | protected $build = false; |
||
12 | |||
13 | protected function checkBuild() |
||
14 | { |
||
15 | if ($this->isBuild()) { |
||
16 | return; |
||
17 | } |
||
18 | $this->build(); |
||
19 | $this->build = true; |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @return bool |
||
24 | */ |
||
25 | public function isBuild(): bool |
||
26 | { |
||
27 | return $this->build === true; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param bool $build |
||
32 | */ |
||
33 | public function setBuild(\Closure $build) |
||
34 | { |
||
35 | $this->build = $build; |
||
36 | } |
||
37 | |||
38 | protected function build() |
||
39 | { |
||
40 | if ($this->build instanceof \Closure) { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
41 | call_user_func($this->build); |
||
42 | } |
||
43 | } |
||
44 | } |