|
6 | 6 |
|
7 | 7 | use Closure; |
8 | 8 | use Illuminate\Console\View\Components\Factory; |
9 | | -use Illuminate\Support\Optional; |
10 | 9 |
|
11 | 10 | class Beautiful extends Notification |
12 | 11 | { |
13 | | - protected Factory|Optional|null $components = null; |
| 12 | + protected ?Factory $components = null; |
14 | 13 |
|
15 | 14 | public function line(string $string, ?string $style = null): void |
16 | 15 | { |
17 | | - $this->components()->line($style, $string, $this->verbosity); |
| 16 | + if ($this->canSpeak()) { |
| 17 | + $this->components()->line($style, $string, $this->verbosity); |
| 18 | + } |
18 | 19 | } |
19 | 20 |
|
20 | 21 | public function info(string $string): void |
21 | 22 | { |
22 | | - $this->components()->info($string, $this->verbosity); |
| 23 | + if ($this->canSpeak()) { |
| 24 | + $this->components()->info($string, $this->verbosity); |
| 25 | + } |
23 | 26 | } |
24 | 27 |
|
25 | 28 | public function warning(string $string): void |
26 | 29 | { |
27 | | - $this->components()->warn($string, $this->verbosity); |
| 30 | + if ($this->canSpeak()) { |
| 31 | + $this->components()->warn($string, $this->verbosity); |
| 32 | + } |
28 | 33 | } |
29 | 34 |
|
30 | 35 | public function task(string $description, Closure $task): void |
31 | 36 | { |
32 | | - $this->components()->task($description, $task); |
| 37 | + if ($this->canSpeak()) { |
| 38 | + $this->components()->task($description, $task); |
| 39 | + } |
33 | 40 | } |
34 | 41 |
|
35 | 42 | public function twoColumn(string $first, string $second): void |
36 | 43 | { |
37 | | - $this->components()->twoColumnDetail($first, $second, $this->verbosity); |
| 44 | + if ($this->canSpeak()) { |
| 45 | + $this->components()->twoColumnDetail($first, $second, $this->verbosity); |
| 46 | + } |
38 | 47 | } |
39 | 48 |
|
40 | | - protected function components(): Factory|Optional |
| 49 | + protected function components(): Factory |
41 | 50 | { |
42 | 51 | if (! is_null($this->components)) { |
43 | 52 | return $this->components; |
44 | 53 | } |
45 | 54 |
|
46 | | - return $this->component = $this->canSpeak() ? new Factory($this->output) : optional(); |
| 55 | + return $this->components = new Factory($this->output); |
47 | 56 | } |
48 | 57 | } |
0 commit comments