ActivationModeFactory::build()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
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