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

SIMC   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 56
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A PobierzListeMiejscowosciWGminie() 0 15 2
A PobierzListeMiejscowosciWRodzajuGminy() 0 17 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:43
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
use mrcnpdlk\Teryt\ResponseModel\Territory\Miejscowosc;
26
27
class SIMC
28
{
29
    /**
30
     * Lista miejscowości znajdujących się we wskazanej gminie.
31
     * Wyszukiwanie odbywa się z uwzględnieniem nazw
32
     *
33
     * @param string $provinceName
34
     * @param string $districtName
35
     * @param string $communeName
36
     *
37
     * @return Miejscowosc[]
38
     * @todo Metoda nie działa
39
     */
40
    public static function PobierzListeMiejscowosciWGminie(string $provinceName, string $districtName, string $communeName)
41
    {
42
        $answer = [];
43
        $res    = Client::getInstance()->request('PobierzListeMiejscowosciWGminie',
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...
44
            [
45
                'wojewodztwo' => $provinceName,
46
                'Powiat'      => $districtName,
47
                'Gmina'       => $communeName,
48
            ])
49
        ;
50
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
51
            $answer[] = new Miejscowosc($p);
52
        };
53
54
        return $answer;
55
    }
56
57
    /**
58
     * Lista miejscowości znajdujących się we wskazanej gminie.
59
     * Wyszukiwanie odbywa się z uwzględnieniem symboli
60
     *
61
     * @param int $tercId
62
     *
63
     * @return Miejscowosc[]
64
     * @todo Zwraca niezgodne typy - połatane
65
     */
66
    public static function PobierzListeMiejscowosciWRodzajuGminy(int $tercId)
67
    {
68
        $answer = [];
69
        $oTerc  = new Terc($tercId);
70
        $res    = Client::getInstance()->request('PobierzListeMiejscowosciWRodzajuGminy',
71
            [
72
                'symbolWoj'  => $oTerc->getProvinceId(),
73
                'symbolPow'  => $oTerc->getDistrictId(),
74
                'symbolGmi'  => $oTerc->getCommuneId(),
75
                'symbolRodz' => $oTerc->getCommuneTypeId(),
76
            ])
77
        ;
78
        foreach (Helper::getPropertyAsArray($res, 'Miejscowosc') as $p) {
79
            $answer[] = new Miejscowosc($p);
80
        };
81
82
        return $answer;
83
    }
84
}
85