Completed
Pull Request — master (#7)
by
unknown
01:10
created

Download   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 46
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setComponent() 0 5 1
A setDataSource() 0 5 1
A setLocalStorage() 0 5 1
A run() 0 10 2
A runLive() 0 10 2
1
<?php
2
3
namespace LoteriaApi\Consumer;
4
5
use Kodify\DownloaderBundle\Service\Downloader;
6
7
class Download
8
{
9
    private $component;
10
    private $datasource;
11
    private $localstorage;
12
    
13
    public function setComponent(Downloader $component)
14
    {
15
        $this->component = $component;
16
        return $this;
17
    }
18
    
19
    public function setDataSource(array $datasource)
20
    {
21
        $this->datasource = $datasource;
22
        return $this;
23
    }
24
    
25
    public function setLocalStorage($localstorage)
26
    {
27
        $this->localstorage = $localstorage;
28
        return $this;
29
    }
30
31
    public function run()
32
    {
33
        foreach ($this->datasource as $concurso) {
34
            $this->component->downloadFile(
35
                $concurso['url'],
36
                $this->localstorage,
37
                $concurso['zip']
38
            );
39
        }
40
    }
41
42
    public function runLive()
43
    {
44
        foreach ($this->datasource as $concurso) {
45
            $this->component->downloadFile(
46
                $concurso['urlLive'],
47
                $this->localstorage,
48
                $concurso['html']
49
            );
50
        }
51
    }
52
}
53