1 | <?php |
||||
2 | |||||
3 | namespace Nip\Locale\Traits; |
||||
4 | |||||
5 | use DirectoryIterator; |
||||
6 | |||||
7 | /** |
||||
8 | * Trait HasSupportedTrait |
||||
9 | * @package Nip\Locale\Traits |
||||
10 | */ |
||||
11 | trait HasSupportedTrait |
||||
12 | { |
||||
13 | protected $supported; |
||||
14 | |||||
15 | 1 | public function getSupported() |
|||
16 | { |
||||
17 | 1 | if (!$this->supported) { |
|||
18 | 1 | $iterator = new DirectoryIterator($this->getDataFolder()); |
|||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
19 | 1 | foreach ($iterator as $file) { |
|||
20 | 1 | if ($file->isFile()) { |
|||
21 | 1 | $fileName = $file->getFilename(); |
|||
22 | 1 | if (substr($fileName, 0, 1) != '_') { |
|||
23 | 1 | $name = str_replace('.php', '', $fileName); |
|||
24 | 1 | $this->supported[] = $name; |
|||
25 | } |
||||
26 | } |
||||
27 | } |
||||
28 | } |
||||
29 | 1 | return $this->supported; |
|||
30 | } |
||||
31 | |||||
32 | /** |
||||
33 | * @param $name |
||||
34 | * @return bool |
||||
35 | */ |
||||
36 | public function isSupported($name) |
||||
37 | { |
||||
38 | return $this->hasDataFile($name); |
||||
0 ignored issues
–
show
It seems like
hasDataFile() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
39 | } |
||||
40 | } |
||||
41 |