| Total Complexity | 6 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | final class CompactorProxy implements Compactor, Serializable |
||
| 23 | { |
||
| 24 | private $createCompactor; |
||
| 25 | private $compactor; |
||
| 26 | |||
| 27 | public function __construct(Closure $createCompactor) |
||
| 28 | { |
||
| 29 | $this->createCompactor = $createCompactor; |
||
| 30 | |||
| 31 | // Instantiate a compactor instead of lazily instantiate it in order to ensure the factory closure is correct |
||
| 32 | // and that the created object is of the created type. Since compactors instantiation should be fast, this is |
||
| 33 | // a minimal overhead which is an acceptable trade-off for providing early errors. |
||
| 34 | $this->getCompactor(); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * {@inheritdoc} |
||
| 39 | */ |
||
| 40 | public function compact(string $file, string $contents): string |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * {@inheritdoc} |
||
| 47 | */ |
||
| 48 | public function serialize(): string |
||
| 49 | { |
||
| 50 | return opis_serialize($this->createCompactor); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * {@inheritdoc} |
||
| 55 | */ |
||
| 56 | public function unserialize($serialized): void |
||
| 59 | } |
||
| 60 | |||
| 61 | public function getCompactor(): Compactor |
||
| 70 |