Total Complexity | 7 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
25 | final class Delete implements Command |
||
26 | { |
||
27 | use JsonHelper; |
||
28 | |||
29 | /** |
||
30 | * @var array|SelectQuery |
||
31 | */ |
||
32 | private $value = []; |
||
33 | |||
34 | private function __construct() |
||
35 | { |
||
36 | } |
||
37 | |||
38 | private function __clone() |
||
39 | { |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @psalm-pure |
||
44 | */ |
||
45 | public static function fromIds(array $ids): self |
||
46 | { |
||
47 | $delete = new self(); |
||
48 | $delete->value = $ids; |
||
49 | |||
50 | return $delete; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @psalm-pure |
||
55 | */ |
||
56 | public static function fromQuery(SelectQuery $query): self |
||
57 | { |
||
58 | $delete = new self(); |
||
59 | $delete->value = $query; |
||
60 | |||
61 | return $delete; |
||
62 | } |
||
63 | |||
64 | public function toJson(): string |
||
65 | { |
||
66 | if ($this->value instanceof SelectQuery) { |
||
67 | return $this->value->toJson(); |
||
68 | } |
||
69 | |||
70 | return self::jsonEncode($this->value); |
||
71 | } |
||
72 | |||
73 | public function getName(): string |
||
76 | } |
||
77 | } |
||
78 |