JednostkaTerytorialna   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 47
ccs 16
cts 18
cp 0.8889
rs 10
c 0
b 0
f 0
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 25 7
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 JednostkaTerytorialna
23
 */
24
class JednostkaTerytorialna extends AbstractResponseModel
25
{
26
    /**
27
     * Nazwa jednostki
28
     *
29
     * @var string
30
     */
31
    public $name;
32
    /**
33
     * Typ jednostki podziału terytorialnego
34
     *
35
     * @var string
36
     */
37
    public $typeName;
38
39
    /**
40
     * JednostkaTerytorialna constructor.
41
     *
42
     * @param \stdClass $oData Obiekt zwrócony z TerytWS1
43
     *
44
     * @throws \mrcnpdlk\Teryt\Exception
45
     */
46 3
    public function __construct(\stdClass $oData)
47
    {
48 3
        $this->provinceId    = $oData->WOJ;
49 3
        $this->districtId    = $oData->POW;
50 3
        $this->communeId     = $oData->GMI;
51 3
        $this->communeTypeId = $oData->RODZ;
52 3
        $this->name          = $oData->NAZWA;
53 3
        $this->typeName      = $oData->NAZWA_DOD;
54 3
        $this->statusDate    = $oData->STAN_NA;
55
56
        try {
57 3
            $this->statusDate = $oData->STAN_NA ? (new \DateTime($oData->STAN_NA))->format('Y-m-d') : null;
58
        } catch (\Exception $e) {
59
            $this->statusDate = null;
60
        }
61
62 3
        if ($this->provinceId && $this->districtId && $this->communeId && $this->communeTypeId) {
63 1
            $this->tercId = (int)sprintf('%s%s%s%s',
64 1
                $this->provinceId,
65 1
                $this->districtId,
66 1
                $this->communeId,
67 1
                $this->communeTypeId);
68
        }
69
70 3
        parent::__construct();
71 3
    }
72
}
73