Total Complexity | 8 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Coverage | 77.78% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | abstract class AbstractColumn |
||
9 | { |
||
10 | public bool $sortable = false; |
||
11 | |||
12 | public bool $html = false; |
||
13 | |||
14 | public string $title; |
||
15 | |||
16 | public string $field; |
||
17 | |||
18 | abstract public static function component(): string; |
||
19 | |||
20 | /** |
||
21 | * AbstractColumn constructor. |
||
22 | * |
||
23 | * @param ...$args - (string $title, string $field, ....) |
||
|
|||
24 | * |
||
25 | * @throws \Exception |
||
26 | */ |
||
27 | 1 | public function __construct(...$args) |
|
28 | { |
||
29 | 1 | if (empty($args[0]) || !is_string($args[0])) { |
|
30 | throw new \Exception('Please specify row title'); |
||
31 | } |
||
32 | |||
33 | 1 | $this->title = $args[0]; |
|
34 | |||
35 | 1 | $this->field = (!empty($args[1]) && is_string($args[1])) ? $args[1] : Str::snake($args[1]); |
|
36 | 1 | } |
|
37 | |||
38 | 1 | public function sortable(bool $sortable = true): self |
|
39 | { |
||
40 | 1 | $this->sortable = $sortable; |
|
41 | |||
42 | 1 | return $this; |
|
43 | } |
||
44 | |||
45 | public function asHtml(bool $html = true): self |
||
46 | { |
||
47 | $this->html = $html; |
||
48 | |||
49 | return $this; |
||
50 | } |
||
51 | |||
52 | 1 | public function headerData(): array |
|
60 | ]; |
||
61 | } |
||
62 | } |
||
63 |