| Total Complexity | 9 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final class Result implements ResultContract |
||
| 13 | { |
||
| 14 | /** @var \Illuminate\Console\Command */ |
||
| 15 | protected $output; |
||
| 16 | |||
| 17 | protected $items = []; |
||
| 18 | |||
| 19 | protected $message = 'No Data'; |
||
| 20 | |||
| 21 | public function setOutput(Command $output): self |
||
| 22 | { |
||
| 23 | $this->output = $output; |
||
| 24 | |||
| 25 | return $this; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function setMessage(string $no_data): self |
||
| 33 | } |
||
| 34 | |||
| 35 | public function show() |
||
| 36 | { |
||
| 37 | empty($this->items) ? $this->warn() : $this->table(); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function merge(array $items): void |
||
| 41 | { |
||
| 42 | $this->items = array_merge($this->items, $items); |
||
| 43 | } |
||
| 44 | |||
| 45 | protected function warn(): void |
||
| 46 | { |
||
| 47 | $this->output->warn($this->message); |
||
| 48 | } |
||
| 49 | |||
| 50 | protected function table(): void |
||
| 53 | } |
||
| 54 | |||
| 55 | protected function headers(): array |
||
| 56 | { |
||
| 57 | $item = Arr::first($this->items); |
||
| 58 | $keys = Arr::keys($item); |
||
| 59 | |||
| 60 | return Arr::transform($keys, function ($value) { |
||
| 61 | return Str::title($value); |
||
| 62 | }); |
||
| 63 | } |
||
| 64 | |||
| 65 | protected function items(): array |
||
| 68 | } |
||
| 69 | } |
||
| 70 |