Factory::getLoteria()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 15
rs 8.8571
cc 5
eloc 12
nc 5
nop 1
1
<?php
2
3
namespace LoteriaApi\Provider;
4
5
use LoteriaApi\Config;
6
use LoteriaApi\Provider\Reader\XmlMegasena;
7
use LoteriaApi\Provider\Reader\XmlQuina;
8
use LoteriaApi\Provider\Reader\XmlLotofacil;
9
use LoteriaApi\Provider\Reader\XmlLotomania;
10
11
use InvalidArgumentException;
12
13
class Factory
14
{
15
    private $config;
16
17
    public function __construct(Config $configPath, Config $configDatasource)
18
    {
19
        $this->config['path'] = $configPath;
20
        $this->config['datasource'] = $configDatasource;
21
    }
22
23
    public function getLoteria($loteria)
24
    {
25
        switch ($loteria) {
26
            case 'megasena':
27
                return new XmlMegasena($this->config['path'], $this->config['datasource']);
28
            case 'quina':
29
                return new XmlQuina($this->config['path'], $this->config['datasource']);
30
            case 'lotofacil':
31
                return new XmlLotofacil($this->config['path'], $this->config['datasource']);
32
            case 'lotomania':
33
                return new XmlLotomania($this->config['path'], $this->config['datasource']);
34
            default:
35
                throw new InvalidArgumentException();
36
        }
37
    }
38
}
39