Miejscowosc::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 10.75

Importance

Changes 0
Metric Value
cc 4
eloc 11
nc 5
nop 1
dl 0
loc 14
ccs 3
cts 12
cp 0.25
crap 10.75
rs 9.9
c 0
b 0
f 0
1
<?php
2
/**
3
 * TERYT-API
4
 *
5
 * Copyright (c) 2017 pudelek.org.pl
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For the full copyright and license information, please view source file
10
 * that is bundled with this package in the file LICENSE
11
 * @author Marcin Pudełek <[email protected]>
12
 */
13
14
/**
15
 * Created by Marcin Pudełek <[email protected]>
16
 * Date: 06.09.2017
17
 */
18
19
namespace mrcnpdlk\Teryt\ResponseModel\Territory;
20
21
/**
22
 * Class Miejscowosc
23
 */
24
class Miejscowosc extends AbstractResponseModel
25
{
26
    /**
27
     * Nazwa miejscowości
28
     *
29
     * @var string
30
     */
31
    public $cityName;
32
    /**
33
     * 7 znakowy identyfikator miejscowości
34
     *
35
     * @var string
36
     */
37
    public $cityId;
38
39
    /**
40
     * Miejscowosc constructor.
41
     *
42
     * @param \stdClass|null $oData Obiekt zwrócony z TerytWS1
43
     *
44
     * @todo Błąd w dokumentacji, zwracana niezgodna ilosc znaków dla PowSymbol i GmiSymbol. Narazie połatałem
45
     *
46
     * @throws \mrcnpdlk\Teryt\Exception
47
     */
48 1
    public function __construct(\stdClass $oData = null)
49
    {
50 1
        if ($oData) {
51
            $this->cityName      = $oData->Nazwa;
52
            $this->cityId        = $oData->Symbol;
53
            $this->provinceId    = $oData->WojSymbol;
54
            $this->provinceName  = $oData->Wojewodztwo;
55
            $this->districtName  = $oData->Powiat;
56
            $this->districtId    = 4 === strlen($oData->PowSymbol) ? substr($oData->PowSymbol, 2, 2) : $oData->PowSymbol;
57
            $this->communeName   = $oData->Gmina;
58
            $this->communeId     = 7 === strlen($oData->GmiSymbol) ? substr($oData->GmiSymbol, 4, 2) : $oData->GmiSymbol;
59
            $this->communeTypeId = $oData->GmiRodzaj;
60
        }
61 1
        parent::__construct();
62 1
    }
63
}
64