ActivationModeFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 11 3
1
<?php
2
3
/*
4
 * This file is part of the AfDontTranslateBundle package
5
 *
6
 * (c) Antoine Froger <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code
10
 */
11
12
namespace Af\Bundle\DontTranslateBundle\ActivationMode;
13
14
/**
15
 * Class ActivationModeFactory
16
 *
17
 * @package Af\Bundle\DontTranslateBundle\ActivationMode
18
 *
19
 * @author  Antoine Froger <[email protected]>
20
 */
21
class ActivationModeFactory
22
{
23
    /**
24
     * @param  string $modeName
25
     *
26
     * @return ActivationModeInterface
27
     * @throws \InvalidArgumentException
28
     */
29
    public function build($modeName)
30
    {
31
        switch (strtolower($modeName)) {
32
            case 'get':
33
                return new Get();
34
            case 'cookie':
35
                return new Cookie();
36
        }
37
38
        throw new \InvalidArgumentException(sprintf('%s is not a valid mode', $modeName));
39
    }
40
}
41