Completed
Push — master ( d8106d...a88754 )
by Marcin
03:16
created

KrsPerson::__construct()   B

Complexity

Conditions 5
Paths 9

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 11
cts 11
cp 1
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 10
nc 9
nop 2
crap 5
1
<?php
2
/**
3
 * MOJEPANSTWO-API
4
 *
5
 * Copyright © 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
declare (strict_types=1);
16
17
namespace mrcnpdlk\MojePanstwo\Model;
18
19
20
use mrcnpdlk\MojePanstwo\Model\KrsPerson\RelatedEntity;
21
22
class KrsPerson extends ModelAbstract
23
{
24
    const CONTEXT = 'krs_osoby';
25
26
    /**
27
     * ID osoby z KRS
28
     *
29
     * @var integer
30
     **/
31
    public $id;
32
    /**
33
     * krs
34
     *
35
     * @var string
36
     **/
37
    public $imie_pierwsze;
38
    /**
39
     * @var string
40
     */
41
    public $imie_drugie;
42
    /**
43
     * @var string
44
     */
45
    public $imiona;
46
    /**
47
     * @var string
48
     */
49
    public $nazwisko;
50
    /**
51
     * @var string
52
     */
53
    public $plec;
54
    /**
55
     * @var string
56
     */
57
    public $data_urodzenia;
58
    /**
59
     * @var integer
60
     */
61
    public $liczba_zalozyciele;
62
    /**
63
     * @var integer
64
     */
65
    public $liczba_reprezentanci;
66
    /**
67
     * @var integer
68
     */
69
    public $liczba_nadzorcow;
70
    /**
71
     * @var integer
72
     */
73
    public $liczba_wspolnicy;
74
    /**
75
     * @var integer
76
     */
77
    public $liczba_akcjonariusze;
78
    /**
79
     * @var int[]
80
     */
81
    public $gmina_id;
82
    /**
83
     * @var string
84
     */
85
    public $str;
86
    /**
87
     * @var \mrcnpdlk\MojePanstwo\Model\KrsPerson\RelatedEntity[]
88
     */
89
    public $podmioty;
90
    /**
91
     * @var string
92
     */
93
    public $privacy;
94
95
96
    /**
97
     * KrsPerson constructor.
98
     *
99
     * @param \stdClass|null $oData
100
     * @param \stdClass|null $oLayers
101
     *
102
     * @throws \mrcnpdlk\MojePanstwo\Exception
103
     */
104 1
    public function __construct(\stdClass $oData = null, \stdClass $oLayers = null)
105
    {
106 1
        parent::__construct($oData);
107 1
        if ($oData) {
108 1
            $this->id             = $this->convertToId($this->id);
109 1
            $this->data_urodzenia = $this->data_urodzenia ? (new \DateTime($this->data_urodzenia))->format('Y-m-d') : null;
110 1
            foreach ((array)$oData->{'krs_osoby.gmina_id'} as $id) {
111 1
                $this->gmina_id[] = (int)$id;
112
            }
113 1
            $tPodmioty = explode('<br/>', $this->str);
114 1
            foreach ($tPodmioty as $desc) {
115 1
                $this->podmioty[] = new RelatedEntity($desc);
116
            }
117
118
        }
119 1
    }
120
}
121