Location::getCoordinates()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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