| Total Complexity | 10 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 11 | trait CanBootTraitsTrait |
||
| 12 | { |
||
| 13 | protected $bootTraits = null; |
||
| 14 | protected $bootedTraits = []; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Initialize any initializable traits on the model. |
||
| 18 | * |
||
| 19 | * @return void |
||
| 20 | */ |
||
| 21 | public function bootTraits() |
||
| 22 | { |
||
| 23 | $needBooting = array_diff($this->getBootTraits(), $this->bootedTraits); |
||
| 24 | foreach ($needBooting as $method) { |
||
| 25 | $this->{$method}(); |
||
| 26 | $this->bootedTraits[] = $method; |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @return null |
||
| 32 | */ |
||
| 33 | public function getBootTraits() |
||
| 34 | { |
||
| 35 | if ($this->bootTraits === null) { |
||
| 36 | $this->initBootTraits(); |
||
| 37 | } |
||
| 38 | return $this->bootTraits; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param null $bootTraits |
||
| 43 | */ |
||
| 44 | public function setBootTraits($bootTraits): void |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @return bool |
||
| 51 | */ |
||
| 52 | public function hasBootTraits() |
||
| 55 | } |
||
| 56 | |||
| 57 | protected function initBootTraits() |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @return array |
||
| 64 | */ |
||
| 65 | protected function generateBootTraits() |
||
| 80 |