Factory   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 4
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
B getLoteria() 0 15 5
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