KrsEntity   A
last analyzed

Complexity

Total Complexity 28

Size/Duplication

Total Lines 557
Duplicated Lines 2.69 %

Coupling/Cohesion

Components 0
Dependencies 10

Test Coverage

Coverage 39.68%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 28
c 1
b 0
f 1
lcom 0
cbo 10
dl 15
loc 557
ccs 25
cts 63
cp 0.3968
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
F __construct() 15 90 28

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Api;
21
use mrcnpdlk\MojePanstwo\Model\KrsEntity\Companies;
22
use mrcnpdlk\MojePanstwo\Model\KrsEntity\Department;
23
use mrcnpdlk\MojePanstwo\Model\KrsEntity\Partner;
24
use mrcnpdlk\MojePanstwo\Model\KrsEntity\Person;
25
use mrcnpdlk\MojePanstwo\Model\KrsEntity\Pkd;
26
use mrcnpdlk\MojePanstwo\Model\KrsEntity\Share;
27
28
class KrsEntity extends ModelAbstract
29
{
30
    const CONTEXT                    = 'krs_podmioty';
31
    const PULL_NONE                  = 0;
32
    const PULL_COMPANIES             = 1;
33
    const PULL_DEPARTMENTS           = 2;
34
    const PULL_PARTNERS              = 4;
35
    const PULL_PKDS                  = 8;
36
    const PULL_SHARES                = 16;
37
    const PULL_PERSON_REPRESENTATION = 32;
38
    const PULL_PERSON_SUPERVISION    = 64;
39
    const PULL_PERSON_PROXY          = 128;
40
    const PULL_PERSON_FOUNDING       = 256;
41
    const PULL_ALL                   = 511;
42
43
44
    /**
45
     * Krs jako int
46
     *
47
     * @var integer
48
     **/
49
    public $id;
50
    /**
51
     * krs
52
     *
53
     * @var string
54
     **/
55
    public $krs;
56
    /**
57
     * nip
58
     *
59
     * @var string|null
60
     **/
61
    public $nip;
62
    /**
63
     * regon
64
     *
65
     * @var string|null
66
     **/
67
    public $regon;
68
    /**
69
     * nazwa
70
     *
71
     * @var string
72
     **/
73
    public $nazwa;
74
    /**
75
     * nazwa_skrocona
76
     *
77
     * @var string
78
     **/
79
    public $nazwa_skrocona;
80
    /**
81
     * adres
82
     *
83
     * @var string
84
     **/
85
    public $adres;
86
    /**
87
     * wojewodztwo_id
88
     *
89
     * @var integer
90
     **/
91
    public $wojewodztwo_id;
92
    /**
93
     * powiat_id
94
     *
95
     * @var integer
96
     **/
97
    public $powiat_id;
98
    /**
99
     * gmina_id
100
     *
101
     * @var integer
102
     **/
103
    public $gmina_id;
104
    /**
105
     * miejscowosc_id
106
     *
107
     * @var integer
108
     **/
109
    public $miejscowosc_id;
110
    /**
111
     * kod_pocztowy_id
112
     *
113
     * @var integer
114
     **/
115
    public $kod_pocztowy_id;
116
    /**
117
     * adres_kod_pocztowy
118
     *
119
     * @var integer
120
     **/
121
    public $adres_kod_pocztowy;
122
    /**
123
     * adres_kraj
124
     *
125
     * @var string
126
     **/
127
    public $adres_kraj;
128
    /**
129
     * adres_lokal
130
     *
131
     * @var string
132
     **/
133
    public $adres_lokal;
134
    /**
135
     * adres_miejscowosc
136
     *
137
     * @var string
138
     **/
139
    public $adres_miejscowosc;
140
    /**
141
     * adres_numer
142
     *
143
     * @var string
144
     **/
145
    public $adres_numer;
146
    /**
147
     * adres_poczta
148
     *
149
     * @var string
150
     **/
151
    public $adres_poczta;
152
    /**
153
     * adres_ulica
154
     *
155
     * @var string
156
     **/
157
    public $adres_ulica;
158
    /**
159
     * siedziba
160
     *
161
     * @var string
162
     **/
163
    public $siedziba;
164
    /**
165
     * cel_dzialania
166
     *
167
     * @var string
168
     **/
169
    public $cel_dzialania;
170
    /**
171
     * data_dokonania_wpisu
172
     *
173
     * @var string
174
     **/
175
    public $data_dokonania_wpisu;
176
    /**
177
     * data_ostatni_wpis
178
     *
179
     * @var string|null
180
     **/
181
    public $data_ostatni_wpis;
182
    /**
183
     * data_rejestracji
184
     *
185
     * @var string
186
     **/
187
    public $data_rejestracji;
188
    /**
189
     * data_sprawdzenia
190
     *
191
     * @var string
192
     **/
193
    public $data_sprawdzenia;
194
    /**
195
     * dotacje_ue_beneficjent_id
196
     *
197
     * @var integer|null
198
     **/
199
    public $dotacje_ue_beneficjent_id;
200
    /**
201
     * email
202
     **/
203
    public $email;
204
    /**
205
     * firma
206
     **/
207
    public $firma;
208
    /**
209
     * forma_prawna_id
210
     *
211
     * @var integer
212
     **/
213
    public $forma_prawna_id;
214
    /**
215
     * forma_prawna_str
216
     *
217
     * @var string
218
     **/
219
    public $forma_prawna_str;
220
    /**
221
     * forma_prawna_typ_id
222
     *
223
     * @var integer
224
     **/
225
    public $forma_prawna_typ_id;
226
    /**
227
     * forma_prawna_typ_str - pole dodaane jako dodatkowe
228
     *
229
     * @var string
230
     **/
231
    public $forma_prawna_typ_str;
232
    /**
233
     * gpw
234
     *
235
     * @var mixed
236
     **/
237
    public $gpw;
238
    /**
239
     * gpw_spolka_id
240
     *
241
     * @var integer|null
242
     **/
243
    public $gpw_spolka_id;
244
    /**
245
     * knf_ostrzezenie_id
246
     *
247
     * @var integer|null
248
     **/
249
    public $knf_ostrzezenie_id;
250
    /**
251
     * liczba_akcji_wszystkich_emisji
252
     *
253
     * @var integer
254
     **/
255
    public $liczba_akcji_wszystkich_emisji;
256
    /**
257
     * liczba_czlonkow_komitetu_zal
258
     *
259
     * @var integer
260
     **/
261
    public $liczba_czlonkow_komitetu_zal;
262
    /**
263
     * liczba_dzialalnosci
264
     *
265
     * @var integer
266
     **/
267
    public $liczba_dzialalnosci;
268
    /**
269
     * liczba_emisji_akcji
270
     *
271
     * @var integer
272
     **/
273
    public $liczba_emisji_akcji;
274
    /**
275
     * liczba_jedynych_akcjonariuszy
276
     *
277
     * @var integer
278
     **/
279
    public $liczba_jedynych_akcjonariuszy;
280
    /**
281
     * liczba_nadzorcow
282
     *
283
     * @var integer
284
     **/
285
    public $liczba_nadzorcow;
286
    /**
287
     * liczba_oddzialow
288
     *
289
     * @var integer
290
     **/
291
    public $liczba_oddzialow;
292
    /**
293
     * liczba_prokurentow
294
     *
295
     * @var integer
296
     **/
297
    public $liczba_prokurentow;
298
    /**
299
     * liczba_reprezentantow
300
     *
301
     * @var integer
302
     **/
303
    public $liczba_reprezentantow;
304
    /**
305
     * liczba_wspolnikow
306
     *
307
     * @var integer
308
     **/
309
    public $liczba_wspolnikow;
310
    /**
311
     * liczba_zmian
312
     *
313
     * @var integer
314
     **/
315
    public $liczba_zmian;
316
    /**
317
     * liczba_zmian_umow
318
     *
319
     * @var integer
320
     **/
321
    public $liczba_zmian_umow;
322
    /**
323
     * nazwa_organu_nadzoru
324
     *
325
     * @var string
326
     **/
327
    public $nazwa_organu_nadzoru;
328
    /**
329
     * nazwa_organu_reprezentacji
330
     *
331
     * @var string
332
     **/
333
    public $nazwa_organu_reprezentacji;
334
    /**
335
     * nieprzedsiebiorca
336
     *
337
     * @var string
338
     * @todo DO wyjasnienia znaczenie pola
339
     **/
340
    public $nieprzedsiebiorca;
341
    /**
342
     * numer_wpisu
343
     *
344
     * @var string
345
     **/
346
    public $numer_wpisu;
347
    /**
348
     * opp
349
     *
350
     * @var string|null
351
     **/
352
    public $opp;
353
    /**
354
     * ostatni_wpis_id
355
     *
356
     * @var integer|null
357
     **/
358
    public $ostatni_wpis_id;
359
    /**
360
     * oznaczenie_sadu
361
     *
362
     * @var string
363
     **/
364
    public $oznaczenie_sadu;
365
    /**
366
     * rejestr
367
     *
368
     * @var string
369
     **/
370
    public $rejestr;
371
    /**
372
     * rejestr_stowarzyszen
373
     *
374
     * @var string
375
     **/
376
    public $rejestr_stowarzyszen;
377
    /**
378
     * sposob_reprezentacji
379
     *
380
     * @var string
381
     **/
382
    public $sposob_reprezentacji;
383
    /**
384
     * sygnatura_akt
385
     *
386
     * @var string
387
     **/
388
    public $sygnatura_akt;
389
    /**
390
     * twitter_account_id
391
     *
392
     * @var string
393
     **/
394
    public $twitter_account_id;
395
    /**
396
     * umowa_spolki_cywilnej
397
     *
398
     * @var string|null
399
     **/
400
    public $umowa_spolki_cywilnej;
401
    /**
402
     * wartosc_czesc_kapitalu_wplaconego
403
     *
404
     * @var integer
405
     **/
406
    public $wartosc_czesc_kapitalu_wplaconego;
407
    /**
408
     * wartosc_kapital_docelowy
409
     *
410
     * @var integer
411
     **/
412
    public $wartosc_kapital_docelowy;
413
    /**
414
     * wartosc_kapital_zakladowy
415
     *
416
     * @var integer
417
     **/
418
    public $wartosc_kapital_zakladowy;
419
    /**
420
     * wartosc_nominalna_akcji
421
     *
422
     * @var integer
423
     **/
424
    public $wartosc_nominalna_akcji;
425
    /**
426
     * wartosc_nominalna_podwyzszenia_kapitalu
427
     *
428
     * @var integer
429
     **/
430
    public $wartosc_nominalna_podwyzszenia_kapitalu;
431
    /**
432
     * wczesniejsza_rejestracja_str
433
     *
434
     * @var string
435
     **/
436
    public $wczesniejsza_rejestracja_str;
437
    /**
438
     * www
439
     *
440
     * @var string
441
     **/
442
    public $www;
443
    /**
444
     * wykreslony
445
     *
446
     * @var string
447
     **/
448
    public $wykreslony;
449
    /**
450
     * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Pkd[]
451
     */
452
    public $dzialalnosci = [];
453
    /**
454
     * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Share[]
455
     */
456
    public $emisje_akcji = [];
457
    /**
458
     * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Companies[]
459
     */
460
    public $firmy = [];
461
    /**
462
     * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Person
463
     */
464
    public $nadzor = [];
465
    /**
466
     * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Person
467
     */
468
    public $prokurenci = [];
469
    /**
470
     * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Person
471
     */
472
    public $reprezentacja = [];
473
    /**
474
     * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Person
475
     */
476
    public $komitetZalozycielski = [];
477
    /**
478
     * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Partner
479
     */
480
    public $wspolnicy = [];
481
    /**
482
     * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Department
483
     */
484
    public $oddzialy = [];
485
486
    /**
487
     * KrsEntity constructor.
488
     *
489
     * @param \stdClass|null $oData
490
     * @param \stdClass|null $oLayers
491
     *
492
     * @throws \mrcnpdlk\MojePanstwo\Exception
493
     */
494 1
    public function __construct(\stdClass $oData = null, \stdClass $oLayers = null)
495
    {
496 1
        parent::__construct($oData);
497 1
        if ($oData) {
498 1
            $this->id                        = $this->convertToId($this->id);
499 1
            $this->wojewodztwo_id            = $this->convertToId($this->wojewodztwo_id);
500 1
            $this->powiat_id                 = $this->convertToId($this->powiat_id);
501 1
            $this->gmina_id                  = $this->convertToId($this->gmina_id);
502 1
            $this->miejscowosc_id            = $this->convertToId($this->miejscowosc_id);
503 1
            $this->kod_pocztowy_id           = $this->convertToId($this->kod_pocztowy_id);
504 1
            $this->forma_prawna_id           = $this->convertToId($this->forma_prawna_id);
505 1
            $this->forma_prawna_typ_id       = $this->convertToId($this->forma_prawna_typ_id);
506 1
            $this->gpw_spolka_id             = $this->convertToId($this->gpw_spolka_id);
507 1
            $this->knf_ostrzezenie_id        = $this->convertToId($this->knf_ostrzezenie_id);
508 1
            $this->dotacje_ue_beneficjent_id = $this->convertToId($this->dotacje_ue_beneficjent_id);
509 1
            $this->opp                       = $this->convertToId($this->opp);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->convertToId($this->opp) can also be of type integer. However, the property $opp is declared as type string|null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
510 1
            $this->ostatni_wpis_id           = $this->convertToId($this->ostatni_wpis_id);
511 1
            $this->regon                     = $this->regon === '0' ? null : $this->regon;
512 1
            $this->data_sprawdzenia          = $this->data_sprawdzenia ? (new \DateTime($this->data_sprawdzenia))->format('Y-m-d H:i:s') : null;
513 1
            switch ($this->forma_prawna_typ_id) {
514 1
                case 1:
515 1
                    $this->forma_prawna_typ_str = 'Organizacje biznesowe';
516 1
                    break;
517
                case 2:
518
                    $this->forma_prawna_typ_str = 'Organizacje pozarządowe';
519
                    break;
520
                case 3:
521
                    $this->forma_prawna_typ_str = 'Samodzielne publiczne zakłady opieki zdrowotnej';
522
                    break;
523
                default:
524
                    $this->forma_prawna_typ_str = null;
525
            }
526
        }
527 1
        if ($oLayers) {
528
            if (isset($oLayers->dzialalnosci)) {
529
                foreach ((array)$oLayers->dzialalnosci as $i) {
530
                    $this->dzialalnosci[] = new Pkd($i);
531
                }
532
            }
533
            if (isset($oLayers->emisje_akcji)) {
534
                foreach ((array)$oLayers->emisje_akcji as $i) {
535
                    $this->emisje_akcji[] = new Share($i);
536
                }
537
            }
538
            if (isset($oLayers->firmy)) {
539
                foreach ((array)$oLayers->firmy as $i) {
540
                    $this->firmy[] = new Companies($i);
541
                }
542
            }
543 View Code Duplication
            if (isset($oLayers->nadzor)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
544
                foreach ((array)$oLayers->nadzor as $i) {
545
                    $this->nadzor[] = new Person($i);
546
                }
547
            }
548 View Code Duplication
            if (isset($oLayers->prokurenci)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
549
                foreach ((array)$oLayers->prokurenci as $i) {
550
                    $this->prokurenci[] = new Person($i);
551
                }
552
            }
553 View Code Duplication
            if (isset($oLayers->reprezentacja)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
554
                foreach ((array)$oLayers->reprezentacja as $i) {
555
                    $this->reprezentacja[] = new Person($i);
556
                }
557
            }
558
            if (isset($oLayers->wspolnicy)) {
559
                foreach ((array)$oLayers->wspolnicy as $i) {
560
                    $this->wspolnicy[] = new Partner($i);
561
                }
562
            }
563
            if (isset($oLayers->oddzialy)) {
564
                foreach ((array)$oLayers->oddzialy as $i) {
565
                    $this->oddzialy[] = new Department($i);
566
                }
567
            }
568
            if (isset($oLayers->jedynyAkcjonariusz) && !empty($oLayers->jedynyAkcjonariusz)) /**
569
             * @todo Implement jedynyAkcjonariusz in object KrsEntity - need example, no doc
570
             */ {
571
                Api::getInstance()
572
                   ->getClient()
573
                   ->getLogger()
574
                   ->warning(sprintf('jedynyAkcjonariusz not defined'))
575
                ;
576
            }
577
        }
578 1
        if (isset($oLayers->komitetZalozycielski)) {
579
            foreach ((array)$oLayers->komitetZalozycielski as $i) {
580
                $this->komitetZalozycielski[] = new Person($i);
581
            }
582
        }
583 1
    }
584
}
585