SectionApiFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A create() 0 9 2
1
<?php
2
namespace Tarioch\EveapiFetcherBundle\Component\Section;
3
4
use JMS\DiExtraBundle\Annotation as DI;
5
use Tarioch\EveapiFetcherBundle\Entity\ApiCall;
6
use Tarioch\EveapiFetcherBundle\Entity\Api;
7
8
/**
9
 * @DI\Service(public=false)
10
 */
11
class SectionApiFactory
12
{
13
    private static $keySections = array('account', 'char', 'corp');
14
15
    private $keySectionApi;
16
    private $noKeySectionApi;
17
18
    /**
19
     * @DI\InjectParams({
20
     * "keySectionApi" = @DI\Inject("tarioch.eveapi_fetcher_bundle.component.section.key_section_api"),
21
     * "noKeySectionApi" = @DI\Inject("tarioch.eveapi_fetcher_bundle.component.section.no_key_section_api")
22
     * })
23
     */
24
    public function __construct(KeySectionApi $keySectionApi, NoKeySectionApi $noKeySectionApi)
25
    {
26
        $this->keySectionApi = $keySectionApi;
27
        $this->noKeySectionApi = $noKeySectionApi;
28
    }
29
30
    /**
31
     *
32
     * @param ApiCall $call
33
     * @return SectionApi
34
     */
35
    public function create(ApiCall $call)
36
    {
37
        $section = $call->getApi()->getSection();
38
        if (in_array($section, self::$keySections)) {
39
            return $this->keySectionApi;
40
        } else {
41
            return $this->noKeySectionApi;
42
        }
43
    }
44
}
45