Location   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A getName() 0 4 1
A getCoordinates() 0 4 1
1
<?php
2
3
namespace AlexeyKuperhstokh\LocationBundle\Location;
4
5
use Symfony\Component\OptionsResolver\Options;
6
use Symfony\Component\OptionsResolver\OptionsResolver;
7
8
class Location
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $options;
14
15
    /**
16
     * @param array $options
17
     */
18
    public function __construct($options)
19
    {
20
        $resolver = new OptionsResolver();
21
        $resolver->setRequired('name');
22
        $resolver->setRequired('coordinates');
23
        $resolver->addAllowedTypes('name', 'string');
24
        $resolver->setNormalizer(
25
            'coordinates',
26
            function (Options $options, $value) {
27
                return new Coordinates($value);
28
            }
29
        );
30
        $this->options = $resolver->resolve($options);
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getName()
37
    {
38
        return $this->options['name'];
39
    }
40
41
    /**
42
     * @return Coordinates
43
     */
44
    public function getCoordinates()
45
    {
46
        return $this->options['coordinates'];
47
    }
48
}
49