| Total Complexity | 5 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Coverage | 66.67% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | trait InitializeTrait |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * Is cache initialized |
||
| 25 | * @var bool|null |
||
| 26 | */ |
||
| 27 | protected $initialized = false; |
||
| 28 | |||
| 29 | |||
| 30 | /** |
||
| 31 | * Enable/disable initialization |
||
| 32 | * |
||
| 33 | * @param bool $enabled |
||
| 34 | */ |
||
| 35 | 395 | public function setInitializeOption(bool $enabled) |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Should initialize |
||
| 42 | * |
||
| 43 | * @return bool |
||
| 44 | */ |
||
| 45 | protected function getInitializeOption(): bool |
||
| 46 | { |
||
| 47 | return $this->initialized !== null; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Mark as initialization required (if enabled) |
||
| 52 | */ |
||
| 53 | 198 | protected function requireInitialization() |
|
| 56 | } |
||
| 57 | |||
| 58 | |||
| 59 | /** |
||
| 60 | * Initialize |
||
| 61 | * |
||
| 62 | * @return void |
||
| 63 | */ |
||
| 64 | abstract protected function initialize(): void; |
||
| 65 | } |
||
| 66 |