Passed
Push — master ( b35614...49fb5f )
by Marcin
07:22
created

JednostkaNomenklaturyNTS::__construct()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 4.0312

Importance

Changes 0
Metric Value
cc 4
eloc 16
nc 5
nop 1
dl 0
loc 21
ccs 14
cts 16
cp 0.875
crap 4.0312
rs 9.7333
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
 *
12
 * @author  Marcin Pudełek <[email protected]>
13
 *
14
 */
15
16
/**
17
 * Created by Marcin Pudełek <[email protected]>
18
 * Date: 06.09.2017
19
 */
20
21
namespace mrcnpdlk\Teryt\ResponseModel\Territory;
22
23
/**
24
 * Class JednostkaNomenklaturyNTS
25
 *
26
 * @package mrcnpdlk\Teryt\ResponseModel\Territory
27
 */
28
class JednostkaNomenklaturyNTS extends AbstractResponseModel
29
{
30
    /**
31
     * Jednoznakowy symbol poziomu
32
     *
33
     * @var string
34
     */
35
    public $level;
36
    /**
37
     * Jednoznakowy symbol regionu
38
     *
39
     * @var string
40
     */
41
    public $regionId;
42
    /**
43
     * Dwuznakowy symbol podregionu
44
     *
45
     * @var string
46
     */
47
    public $subregionId;
48
    /**
49
     * Nazwa jednostki
50
     *
51
     * @var string
52
     */
53
    public $name;
54
    /**
55
     * Typ jednostki podziału terytorialnego
56
     *
57
     * @var string
58
     */
59
    public $typeName;
60
61
    /**
62
     * JednostkaNomenklaturyNTS constructor.
63
     *
64
     * @param \stdClass|null $oData
65
     *
66
     * @throws \mrcnpdlk\Teryt\Exception
67
     */
68 1
    public function __construct(\stdClass $oData = null)
69
    {
70 1
        if (null !== $oData) {
71 1
            parent::__construct($oData);
72 1
            $this->communeId     = $oData->GMI;
73 1
            $this->name          = $oData->NAZWA;
74 1
            $this->typeName      = $oData->NAZWA_DOD;
75 1
            $this->subregionId   = $oData->PODREG;
76 1
            $this->districtId    = $oData->POW;
77 1
            $this->level         = $oData->POZIOM;
78 1
            $this->regionId      = $oData->REGION;
79 1
            $this->communeTypeId = $oData->RODZ;
80 1
            $this->provinceId    = $oData->WOJ;
81
82
            try {
83 1
                $this->statusDate = $oData->STAN_NA ? (new \DateTime($oData->STAN_NA))->format('Y-m-d') : null;
84
            } catch (\Exception $e) {
85
                $this->statusDate = null;
86
            }
87
88 1
            $this->expandData();
89
        }
90 1
    }
91
}
92