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

JednostkaNomenklaturyNTS::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

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