Completed
Push — master ( e1f5ea...1fc073 )
by Frank
02:44
created

I18nRoute::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
crap 3
1
<?php
2
3
namespace FrankDeJonge\SymfonyI18nRouting\Routing\Annotation;
4
5
use InvalidArgumentException;
6
use function is_array;
7
use Symfony\Component\Routing\Annotation\Route;
8
use function ucfirst;
9
10
/**
11
 * I18nRoute annotation.
12
 *
13
 * @Annotation
14
 * @Target({"CLASS", "METHOD"})
15
 */
16
class I18nRoute extends Route
17
{
18
    private $locales = [];
19
20 56
    public function __construct(array $data)
21
    {
22 56
        if (isset($data['value'])) {
23 32
            $data[is_array($data['value']) ? 'locales' : 'path'] = $data['value'];
24 32
            unset($data['value']);
25
        }
26
27 56
        parent::__construct($data);
28 54
    }
29
30 32
    public function getLocales()
31
    {
32 32
        return $this->locales;
33
    }
34
35 20
    public function setLocales(array $locales)
36
    {
37 20
        $this->locales = $locales;
38
    }
39
}