Completed
Push — master ( 84750e...bb7498 )
by Marcin
02:41
created

ULIC   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A PobierzListeUlicDlaMiejscowosci() 0 22 2
1
<?php
2
/**
3
 * TERYT-API
4
 *
5
 * Copyright (c) 2017 pudelek.org.pl
6
 *
7
 * For the full copyright and license information, please view source file
8
 * that is bundled with this package in the file LICENSE
9
 *
10
 * Author Marcin Pudełek <[email protected]>
11
 *
12
 */
13
14
/**
15
 * Created by Marcin.
16
 * Date: 10.09.2017
17
 * Time: 12:41
18
 */
19
20
namespace mrcnpdlk\Teryt\Api;
21
22
23
use mrcnpdlk\Teryt\Helper;
24
use mrcnpdlk\Teryt\Model\Terc;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, mrcnpdlk\Teryt\Api\Terc. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
25
26
class ULIC
27
{
28
    /**
29
     * Lista ulic we wskazanej miejscowości
30
     *
31
     * @param int    $tercId
32
     * @param string $cityId
33
     * @param bool   $asAddress
34
     *
35
     * @return UlicaDrzewo[]
36
     * @todo Metoda nie działa poprawnie
37
     */
38
    public static function PobierzListeUlicDlaMiejscowosci(int $tercId, string $cityId, bool $asAddress = false)
39
    {
40
        $answer = [];
41
        $oTerc  = new Terc($tercId);
42
        $res    = Client::getInstance()->request('PobierzListeUlicDlaMiejscowosci',
0 ignored issues
show
Bug introduced by
The type mrcnpdlk\Teryt\Api\Client was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
43
            [
44
                'Woj'               => $oTerc->getProvinceId(),
45
                'Pow'               => $oTerc->getDistrictId(),
46
                'Gmi'               => $oTerc->getCommuneId(),
47
                'Rodz'              => $oTerc->getCommuneTypeId(),
48
                'msc'               => $cityId,
49
                'czyWersjaUrzedowa' => !$asAddress,
50
                'czyWersjaAdresowa' => $asAddress,
51
            ]
52
        )
53
        ;
54
55
        foreach (Helper::getPropertyAsArray($res, 'UlicaDrzewo') as $p) {
56
            $answer[] = new UlicaDrzewo($p);
0 ignored issues
show
Bug introduced by
The type mrcnpdlk\Teryt\Api\UlicaDrzewo was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
57
        };
58
59
        return $answer;
60
    }
61
}
62