JednostkaNomenklaturyNTS::__construct()   A
last analyzed

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
 * @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 JednostkaNomenklaturyNTS
23
 */
24
class JednostkaNomenklaturyNTS extends AbstractResponseModel
25
{
26
    /**
27
     * Jednoznakowy symbol poziomu
28
     *
29
     * @var string
30
     */
31
    public $level;
32
    /**
33
     * Jednoznakowy symbol regionu
34
     *
35
     * @var string
36
     */
37
    public $regionId;
38
    /**
39
     * Dwuznakowy symbol podregionu
40
     *
41
     * @var string
42
     */
43
    public $subregionId;
44
    /**
45
     * Nazwa jednostki
46
     *
47
     * @var string
48
     */
49
    public $name;
50
    /**
51
     * Typ jednostki podziału terytorialnego
52
     *
53
     * @var string
54
     */
55
    public $typeName;
56
57
    /**
58
     * JednostkaNomenklaturyNTS constructor.
59
     *
60
     * @param \stdClass|null $oData
61
     *
62
     * @throws \mrcnpdlk\Teryt\Exception
63
     */
64 1
    public function __construct(\stdClass $oData = null)
65
    {
66 1
        if (null !== $oData) {
67 1
            parent::__construct();
68 1
            $this->communeId     = $oData->GMI;
69 1
            $this->name          = $oData->NAZWA;
70 1
            $this->typeName      = $oData->NAZWA_DOD;
71 1
            $this->subregionId   = $oData->PODREG;
72 1
            $this->districtId    = $oData->POW;
73 1
            $this->level         = $oData->POZIOM;
74 1
            $this->regionId      = $oData->REGION;
75 1
            $this->communeTypeId = $oData->RODZ;
76 1
            $this->provinceId    = $oData->WOJ;
77
78
            try {
79 1
                $this->statusDate = $oData->STAN_NA ? (new \DateTime($oData->STAN_NA))->format('Y-m-d') : null;
80
            } catch (\Exception $e) {
81
                $this->statusDate = null;
82
            }
83
84 1
            $this->expandData();
85
        }
86 1
    }
87
}
88