1 | <?php |
||
2 | |||
3 | namespace Maestriam\Samurai\Entities; |
||
4 | |||
5 | use Maestriam\FileSystem\Support\FileSystem; |
||
6 | use Maestriam\Samurai\Entities\Theme; |
||
7 | use Maestriam\Samurai\Entities\Foundation; |
||
8 | |||
9 | class Base extends Foundation |
||
10 | { |
||
11 | /** |
||
12 | * {@inheritDoc} |
||
13 | */ |
||
14 | public function all() : array |
||
15 | { |
||
16 | $themes = []; |
||
17 | |||
18 | foreach($this->readBase() as $folder) { |
||
19 | |||
20 | $theme = $this->find($folder); |
||
21 | |||
22 | if ($theme == null) { |
||
23 | continue; |
||
24 | } |
||
25 | |||
26 | $themes[] = $theme; |
||
27 | } |
||
28 | |||
29 | return $themes; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * {@inheritDoc} |
||
34 | */ |
||
35 | public function current() : ?Theme |
||
36 | { |
||
37 | $key = $this->config()->env(); |
||
38 | |||
39 | $current = $this->env()->get($key); |
||
40 | |||
41 | if (! $current) { |
||
42 | return null; |
||
43 | } |
||
44 | |||
45 | return $this->find($current); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * {@inheritDoc} |
||
50 | */ |
||
51 | public function first() : ?Theme |
||
52 | { |
||
53 | $folders = $this->readBase(); |
||
54 | |||
55 | if (empty($folders)) { |
||
56 | return null; |
||
57 | } |
||
58 | |||
59 | $first = array_shift($folders); |
||
60 | |||
61 | return $this->find($first); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * {@inheritDoc} |
||
66 | */ |
||
67 | public function any() : ?Theme |
||
68 | { |
||
69 | if ($this->empty()) { |
||
70 | return null; |
||
71 | } |
||
72 | |||
73 | $current = $this->current(); |
||
74 | |||
75 | return $current ?? $this->first(); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * {@inheritDoc} |
||
80 | */ |
||
81 | public function empty() : bool |
||
82 | { |
||
83 | $dir = $this->readBase(); |
||
84 | |||
85 | return (empty($dir)) ? true : false; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Limpa o cache da aplicação Laravel |
||
90 | * |
||
91 | * @todo Pensar em um lugar melhor para deixar essa função. |
||
92 | * @return void |
||
93 | */ |
||
94 | public function clean() |
||
95 | { |
||
96 | return $this->file()->clearCache(); |
||
0 ignored issues
–
show
|
|||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Retorna a instância de um tema. |
||
101 | * Se o tema não existir no projeto, retorna nulo. |
||
102 | * |
||
103 | * @param string $package |
||
104 | * @return Theme|null |
||
105 | */ |
||
106 | private function find(string $package) : ?Theme |
||
107 | { |
||
108 | $theme = new Theme($package); |
||
109 | |||
110 | return $theme->find(); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Retorna a lista de temas cadastrados no projeto |
||
115 | * |
||
116 | * @return array |
||
117 | */ |
||
118 | private function readBase() : array |
||
119 | { |
||
120 | $path = $this->config()->base(); |
||
121 | |||
122 | return FileSystem::folder($path)->read(2); |
||
123 | } |
||
124 | } |
||
125 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.