Ulica::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 25
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 19
nc 5
nop 1
dl 0
loc 25
ccs 0
cts 19
cp 0
crap 20
rs 9.6333
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 Ulica
23
 */
24
class Ulica extends AbstractResponseModel
25
{
26
    /**
27
     * Zawiera cechę ulicy
28
     *
29
     * @var string
30
     */
31
    public $streetIdentity;
32
    /**
33
     * Nazwa ulicy
34
     *
35
     * @var string
36
     */
37
    public $streetName;
38
    /**
39
     * Identyfikator ulicy
40
     *
41
     * @var string
42
     */
43
    public $streetId;
44
    /**
45
     * 7 znakowy identyfikator miejscowości
46
     *
47
     * @var string
48
     */
49
    public $cityId;
50
    /**
51
     * Nazwa ulicy
52
     *
53
     * @var string
54
     */
55
    public $cityName;
56
57
    /**
58
     * Ulica constructor.
59
     *
60
     * @param \stdClass|null $oData Obiekt zwrócony z TerytWS1
61
     *
62
     * @throws \mrcnpdlk\Teryt\Exception
63
     */
64
    public function __construct(\stdClass $oData = null)
65
    {
66
        if ($oData) {
67
            $this->streetIdentity = $oData->Cecha;
68
            $this->communeTypeId  = $oData->GmiRodzaj ?? $oData->RodzGmi ?? null;
69
            $this->communeId      = $oData->GmiSymbol ?? $oData->Gmi ?? null;
70
            $this->communeName    = $oData->Gmina     ?? null;
71
            $this->cityId         = $oData->IdentyfikatorMiejscowosci;
72
            $this->streetId       = $oData->IdentyfikatorUlicy ?? $oData->SymbolUlicy ?? null;
73
            $this->streetName     = $oData->Nazwa              ?? null;
74
            $this->cityName       = $oData->NazwaMiejscowosci  ?? null;
75
            $this->districtId     = $oData->PowSymbol          ?? $oData->Pow          ?? null;
76
            $this->districtName   = $oData->Powiat             ?? null;
77
            $this->provinceId     = $oData->WojSymbol          ?? $oData->Woj          ?? null;
78
            $this->provinceName   = $oData->Wojewodztwo        ?? null;
79
80
            $dataStanu = $oData->DataStanu ?? $oData->StanNa ?? null;
81
            try {
82
                $this->statusDate = $dataStanu ? (new \DateTime($dataStanu))->format('Y-m-d') : null;
83
            } catch (\Exception $e) {
84
                $this->statusDate = null;
85
            }
86
        }
87
88
        parent::__construct();
89
    }
90
}
91