1 | <?php |
||
7 | class Downloader |
||
8 | { |
||
9 | private $config; |
||
10 | |||
11 | 78 | public function __construct(Config $config) |
|
15 | |||
16 | 78 | public function sync($type = 'xml') |
|
17 | { |
||
18 | // Download quran data |
||
19 | 78 | foreach ($this->config->get('translations') as $tr) { |
|
|
|||
20 | 78 | $file = $this->config->get('storage_path').'/'.$tr.'.'.$type; |
|
21 | |||
22 | 78 | if (!file_exists($file)) { |
|
23 | $url = 'http://tanzil.net/trans/?transID='.$tr.'&type='.$type; |
||
24 | 26 | $this->download($url, $file); |
|
25 | } |
||
26 | 52 | } |
|
27 | 78 | } |
|
28 | |||
29 | public function download($url, $destination) |
||
35 | } |
||
36 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.