| Total Complexity | 7 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 24 | final class Commit implements Command |
||
| 25 | { |
||
| 26 | use JsonHelper; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @psalm-var array{waitSearcher: ?bool, expungeDeletes: ?bool} |
||
| 30 | */ |
||
| 31 | private array $options = [ |
||
| 32 | 'waitSearcher' => null, |
||
| 33 | 'expungeDeletes' => null, |
||
| 34 | ]; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @psalm-pure |
||
| 38 | */ |
||
| 39 | public static function create(): self |
||
| 40 | { |
||
| 41 | return new self(); |
||
| 42 | } |
||
| 43 | |||
| 44 | public function enableWaitSearcher(): self |
||
| 45 | { |
||
| 46 | $commit = clone $this; |
||
| 47 | $commit->options['waitSearcher'] = true; |
||
| 48 | |||
| 49 | return $commit; |
||
| 50 | } |
||
| 51 | |||
| 52 | public function disableWaitSearcher(): self |
||
| 58 | } |
||
| 59 | |||
| 60 | public function enableExpungeDeletes(): self |
||
| 61 | { |
||
| 62 | $commit = clone $this; |
||
| 63 | $commit->options['expungeDeletes'] = true; |
||
| 64 | |||
| 65 | return $commit; |
||
| 66 | } |
||
| 67 | |||
| 68 | public function disableExpungeDeletes(): self |
||
| 69 | { |
||
| 70 | $commit = clone $this; |
||
| 71 | $commit->options['expungeDeletes'] = false; |
||
| 72 | |||
| 73 | return $commit; |
||
| 74 | } |
||
| 75 | |||
| 76 | public function toJson(): string |
||
| 77 | { |
||
| 78 | return self::jsonEncode(array_filter($this->options, static function ($option): bool { return null !== $option; }), JSON_FORCE_OBJECT); |
||
| 79 | } |
||
| 80 | |||
| 81 | public function getName(): string |
||
| 84 | } |
||
| 85 | } |
||
| 86 |