Test Failed
Pull Request — master (#11)
by
unknown
01:58
created

Details::osmId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of PHP Nominatim.
7
 * (c) Maxime Hélias <[email protected]>
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace maxh\Nominatim;
13
14
use maxh\Nominatim\Exceptions\InvalidParameterException;
15
16
/**
17
 * Lookup details about a single place by id.
18
 *
19
 * @see http://wiki.openstreetmap.org/wiki/Nominatim
20
 */
21
class Details extends Query
22
{
23
    /**
24
     * Constructor.
25
     *
26
     * @param array $query Default value for this query
27
     */
28
    public function __construct(array &$query = [])
29
    {
30
        parent::__construct($query);
31
32
        $this->setPath('details');
33
34
        $this->acceptedFormat[] = 'html';
35
        $this->acceptedFormat[] = 'jsonv2';
36
    }
37
38
    /**
39
     * Place information by placeId.
40
     *
41
     * @return Details
42
     */
43
    public function placeId(int $placeId): self
44
    {
45
        $this->query['place_id'] = $placeId;
46
47
        return $this;
48
    }
49
50
    /**
51
     * Place information by osmtype and osmid.
52
     *
53
     * @throws InvalidParameterException
54
     *
55
     * @return Details
56
     */
57 View Code Duplication
    public function osmId(string $osmType, int $osmId): self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
    {
59
        if (!\in_array($osmType, Consts\OsmTypes::all(), true)) {
60
            throw new InvalidParameterException('Osm type is invalid');
61
        }
62
63
        $this->query['osmtype'] = $osmType;
64
        $this->query['osmid'] = $osmId;
65
66
        return $this;
67
    }
68
}
69