GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 1faea8...2295f4 )
by Eric
03:10
created

PathElevationRequest   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 115
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 13
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 115
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A hasPaths() 0 4 1
A getPaths() 0 4 1
A setPaths() 0 5 1
A addPaths() 0 6 2
A hasPath() 0 4 1
A addPath() 0 6 2
A removePath() 0 5 1
A getSamples() 0 4 1
A setSamples() 0 4 1
A build() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Service\Elevation\Request;
13
14
use Ivory\GoogleMap\Service\Base\Location\LocationInterface;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19
class PathElevationRequest implements ElevationRequestInterface
20
{
21
    /**
22
     * @var LocationInterface[]
23
     */
24
    private $paths = [];
25
26
    /**
27
     * @var int
28
     */
29
    private $samples;
30
31
    /**
32
     * @param LocationInterface[] $paths
33
     * @param int                 $samples
34
     */
35
    public function __construct(array $paths, $samples = 3)
36
    {
37
        $this->setPaths($paths);
38
        $this->setSamples($samples);
39
    }
40
41
    /**
42
     * @return bool
43
     */
44
    public function hasPaths()
45
    {
46
        return !empty($this->paths);
47
    }
48
49
    /**
50
     * @return LocationInterface[]
51
     */
52
    public function getPaths()
53
    {
54
        return $this->paths;
55
    }
56
57
    /**
58
     * @param LocationInterface[] $paths
59
     */
60
    public function setPaths(array $paths)
61
    {
62
        $this->paths = [];
63
        $this->addPaths($paths);
64
    }
65
66
    /**
67
     * @param LocationInterface[] $paths
68
     */
69
    public function addPaths(array $paths)
70
    {
71
        foreach ($paths as $path) {
72
            $this->addPath($path);
73
        }
74
    }
75
76
    /**
77
     * @param LocationInterface $path
78
     *
79
     * @return bool
80
     */
81
    public function hasPath(LocationInterface $path)
82
    {
83
        return in_array($path, $this->paths, true);
84
    }
85
86
    /**
87
     * @param LocationInterface $path
88
     */
89
    public function addPath(LocationInterface $path)
90
    {
91
        if (!$this->hasPath($path)) {
92
            $this->paths[] = $path;
93
        }
94
    }
95
96
    /**
97
     * @param LocationInterface $path
98
     */
99
    public function removePath(LocationInterface $path)
100
    {
101
        unset($this->paths[array_search($path, $this->paths, true)]);
102
        $this->paths = array_values($this->paths);
103
    }
104
105
    /**
106
     * @return int
107
     */
108
    public function getSamples()
109
    {
110
        return $this->samples;
111
    }
112
113
    /**
114
     * @param int $samples
115
     */
116
    public function setSamples($samples)
117
    {
118
        $this->samples = $samples;
119
    }
120
121
    /**
122
     * {@inheritdoc}
123
     */
124
    public function build()
125
    {
126
        return [
127
            'path' => implode('|', array_map(function (LocationInterface $path) {
128
                return $path->build();
129
            }, $this->paths)),
130
            'samples' => $this->samples,
131
        ];
132
    }
133
}
134