Indi::getAttr()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 2
nc 2
nop 1
1
<?php
2
/**
3
 * php-gedcom.
4
 *
5
 * php-gedcom is a library for parsing, manipulating, importing and exporting
6
 * GEDCOM 5.5 files in PHP 5.3+.
7
 *
8
 * @author          Kristopher Wilson <[email protected]>
9
 * @copyright       Copyright (c) 2010-2013, Kristopher Wilson
10
 * @license         MIT
11
 *
12
 * @link            http://github.com/mrkrstphr/php-gedcom
13
 */
14
15
namespace Gedcom\Record;
16
17
/**
18
 * Class Indi.
19
 */
20
class Indi extends \Gedcom\Record implements Noteable, Objectable, Sourceable
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $id;
26
27
    /**
28
     * @var string
29
     */
30
    protected $gid;
31
32
    /**
33
     * @var string
34
     */
35
    protected $uid;
36
37
    /**
38
     * @var string
39
     */
40
    protected $resn;
41
    /**
42
     * @var Indi\Name[]
43
     */
44
    protected $name = [];
45
    /**
46
     * @var string
47
     */
48
    protected $sex;
49
50
    /**
51
     * @var Indi\Even[]
52
     */
53
    protected $even = [];
54
    /**
55
     * @var Indi\Attr[]
56
     */
57
    protected $attr = [];
58
    /**
59
     * @var Indi\Bapl
60
     */
61
    protected $bapl = [];
62
63
    /**
64
     * @var Indi\Conl
65
     */
66
    protected $conl = [];
67
68
    /**
69
     * @var Indi\Endl
70
     */
71
    protected $endl = [];
72
73
    /**
74
     * @var Indi\Slgc
75
     */
76
    protected $slgc = [];
77
78
    /**
79
     * @var Indi\Famc[]
80
     */
81
    protected $famc = [];
82
    /**
83
     * @var Indi\Fams[]
84
     */
85
    protected $fams = [];
86
    /**
87
     * @var string[]
88
     */
89
    protected $subm = [];
90
    /**
91
     * @var string[]
92
     */
93
    protected $alia = [];
94
    /**
95
     * @var string[]
96
     */
97
    protected $anci = [];
98
    /**
99
     * @var string[]
100
     */
101
    protected $desi = [];
102
    /**
103
     * @var string
104
     */
105
    protected $rfn;
106
    /**
107
     * @var string
108
     */
109
    protected $afn;
110
    /**
111
     * @var Refn[]
112
     */
113
    protected $refn = [];
114
    /**
115
     * @var string
116
     */
117
    protected $rin;
118
119
    /**
120
     * @var string
121
     */
122
    protected $chan;
123
124
    /**
125
     * @var Indi\Note[]
126
     */
127
    protected $note = [];
128
129
    /**
130
     * @var Obje[]
131
     */
132
    protected $obje = [];
133
134
    /**
135
     * @var Sour[]
136
     */
137
    protected $sour = [];
138
139
    /**
140
     * @var Indi\Asso[]
141
     */
142
    protected $asso = [];
143
144
    protected $deathday = [];
145
146
    protected $birt;
147
148
    protected $buri;
149
150
    protected $deat;
151
152
    protected $chr;
153
154
    public function setBirt($birt)
155
    {
156
        $this->birt = $birt;
157
    }
158
159
    public function getBirt()
160
    {
161
        return $this->birt;
162
    }
163
164
    public function setBuri($buri)
165
    {
166
        $this->buri = $buri;
167
    }
168
169
    public function getBuri()
170
    {
171
        return $this->buri;
172
    }
173
174
    public function setDeat($deat)
175
    {
176
        $this->deat = $deat;
177
    }
178
179
    public function getDeat()
180
    {
181
        return $this->deat;
182
    }
183
184
    public function setChr($chr)
185
    {
186
        $this->chr = $chr;
187
    }
188
189
    public function getChr()
190
    {
191
        return $this->chr;
192
    }
193
194
    /**
195
     * @param string $id
196
     *
197
     * @return Indi
198
     */
199
    public function setId($id = '')
200
    {
201
        $this->id = $id;
202
203
        return $this;
204
    }
205
206
    /**
207
     * @return string
208
     */
209
    public function getId()
210
    {
211
        return $this->id;
212
    }
213
214
    /**
215
     * @param string $id
216
     *
217
     * @return Indi
218
     */
219
    public function setGid($gid = '')
220
    {
221
        $this->gid = $gid;
222
223
        return $this;
224
    }
225
226
    /**
227
     * @return string
228
     */
229
    public function getGid()
230
    {
231
        return $this->gid;
232
    }
233
234
    /**
235
     * @param string $uid
236
     *
237
     * @return Indi
238
     */
239
    public function setUid($uid = '')
240
    {
241
        $this->uid = $uid;
242
243
        return $this;
244
    }
245
246
    /**
247
     * @return string
248
     */
249
    public function getUid()
250
    {
251
        return $this->uid;
252
    }
253
254
    /**
255
     * @param Indi\Name $name
256
     *
257
     * @return Indi
258
     */
259
    public function addName($name = [])
260
    {
261
        $this->name[] = $name;
262
263
        return $this;
264
    }
265
266
    /**
267
     * @return Indi\Name[]
268
     */
269
    public function getName()
270
    {
271
        return $this->name;
272
    }
273
274
    /**
275
     * @param Indi\Attr $attr
276
     *
277
     * @return Indi
278
     */
279
    public function addAttr($attr = [])
280
    {
281
        $attrName = $attr->getType();
282
283
        if (!array_key_exists($attrName, $this->attr)) {
284
            $this->attr[$attrName] = [];
285
        }
286
287
        $this->attr[$attrName][] = $attr;
288
289
        return $this;
290
    }
291
292
    /**
293
     * @return Indi\Attr[]
294
     */
295
    public function getAllAttr()
296
    {
297
        return $this->attr;
298
    }
299
300
    /**
301
     * @return Indi\Attr[]
302
     */
303
    public function getAttr($key = '')
304
    {
305
        if (isset($this->attr[strtoupper($key)])) {
306
            return $this->attr[strtoupper($key)];
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->attr[strtoupper($key)] returns the type Gedcom\Record\Indi\Attr which is incompatible with the documented return type Gedcom\Record\Indi\Attr[].
Loading history...
307
        }
308
    }
309
310
    /**
311
     * @param Indi\Even $even
312
     *
313
     * @return Indi
314
     */
315
    public function addEven($even = [])
316
    {
317
        $evenName = $even->getType();
318
319
        if (!array_key_exists($evenName, $this->even)) {
320
            $this->even[$evenName] = [];
321
        }
322
323
        $this->even[$evenName][] = $even;
324
325
        return $this;
326
    }
327
328
    /**
329
     * @return array
330
     */
331
    public function getAllEven()
332
    {
333
        return $this->even;
334
    }
335
336
    /**
337
     * @return array
338
     */
339
    public function getEven($key = '')
340
    {
341
        if (isset($this->even[strtoupper($key)])) {
342
            return $this->even[strtoupper($key)];
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->even[strtoupper($key)] returns the type Gedcom\Record\Indi\Even which is incompatible with the documented return type array.
Loading history...
343
        }
344
    }
345
346
    /**
347
     * @param Indi\Asso $asso
348
     *
349
     * @return Indi
350
     */
351
    public function addAsso($asso = [])
352
    {
353
        $this->asso[] = $asso;
354
355
        return $this;
356
    }
357
358
    /**
359
     * @return array
360
     */
361
    public function getAsso()
362
    {
363
        return $this->asso;
364
    }
365
366
    /**
367
     * @param Refn $ref
368
     *
369
     * @return Indi
370
     */
371
    public function addRefn($ref = [])
372
    {
373
        $this->refn[] = $ref;
374
375
        return $this;
376
    }
377
378
    /**
379
     * @return Refn[]
380
     */
381
    public function getRefn()
382
    {
383
        return $this->refn;
384
    }
385
386
    /**
387
     * @param \Gedcom\Record\NoteRef $note
388
     *
389
     * @return Indi
390
     */
391
    public function addNote($note = [])
392
    {
393
        $this->note[] = $note;
394
395
        return $this;
396
    }
397
398
    /**
399
     * @return array
400
     */
401
    public function getNote()
402
    {
403
        return $this->note;
404
    }
405
406
    /**
407
     * @param ObjeRef $obje
408
     *
409
     * @return Indi
410
     */
411
    public function addObje($obje = [])
412
    {
413
        $this->obje[] = $obje;
414
415
        return $this;
416
    }
417
418
    /**
419
     * @return array
420
     */
421
    public function getObje()
422
    {
423
        return $this->obje;
424
    }
425
426
    /**
427
     * @param SourRef $sour
428
     *
429
     * @return Indi
430
     */
431
    public function addSour($sour = [])
432
    {
433
        $this->sour[] = $sour;
434
435
        return $this;
436
    }
437
438
    /**
439
     * @return array
440
     */
441
    public function getSour()
442
    {
443
        return $this->sour;
444
    }
445
446
    /**
447
     * @param string $indi
448
     *
449
     * @return Indi
450
     */
451
    public function addAlia($indi = '')
452
    {
453
        $this->alia[] = $indi;
454
455
        return $this;
456
    }
457
458
    /**
459
     * @return array
460
     */
461
    public function getAlia()
462
    {
463
        return $this->alia;
464
    }
465
466
    /**
467
     * @param Indi\Famc $famc
468
     *
469
     * @return Indi
470
     */
471
    public function addFamc($famc = [])
472
    {
473
        $this->famc[] = $famc;
474
475
        return $this;
476
    }
477
478
    /**
479
     * @return array
480
     */
481
    public function getFamc()
482
    {
483
        return $this->famc;
484
    }
485
486
    /**
487
     * @param Indi\Fams $fams
488
     *
489
     * @return Indi
490
     */
491
    public function addFams($fams = [])
492
    {
493
        $this->fams[] = $fams;
494
495
        return $this;
496
    }
497
498
    /**
499
     * @return array
500
     */
501
    public function getFams()
502
    {
503
        return $this->fams;
504
    }
505
506
    /**
507
     * @param string $subm
508
     *
509
     * @return Indi
510
     */
511
    public function addAnci($subm = '')
512
    {
513
        $this->anci[] = $subm;
514
515
        return $this;
516
    }
517
518
    /**
519
     * @return string[]
520
     */
521
    public function getAnci()
522
    {
523
        return $this->anci;
524
    }
525
526
    /**
527
     * @param string $subm
528
     *
529
     * @return Indi
530
     */
531
    public function addDesi($subm = '')
532
    {
533
        $this->desi[] = $subm;
534
535
        return $this;
536
    }
537
538
    /**
539
     * @return string[]
540
     */
541
    public function getDesi()
542
    {
543
        return $this->desi;
544
    }
545
546
    /**
547
     * @param string $subm
548
     *
549
     * @return Indi
550
     */
551
    public function addSubm($subm = '')
552
    {
553
        $this->subm[] = $subm;
554
555
        return $this;
556
    }
557
558
    /**
559
     * @return string[]
560
     */
561
    public function getSubm()
562
    {
563
        return $this->subm;
564
    }
565
566
    /**
567
     * @param string $resn
568
     *
569
     * @return Indi
570
     */
571
    public function setResn($resn = '')
572
    {
573
        $this->resn = $resn;
574
575
        return $this;
576
    }
577
578
    /**
579
     * @return string
580
     */
581
    public function getResn()
582
    {
583
        return $this->resn;
584
    }
585
586
    /**
587
     * @param string $sex
588
     *
589
     * @return Indi
590
     */
591
    public function setSex($sex = '')
592
    {
593
        $this->sex = $sex;
594
595
        return $this;
596
    }
597
598
    /**
599
     * @return string
600
     */
601
    public function getSex()
602
    {
603
        return $this->sex;
604
    }
605
606
    /**
607
     * @param string $rfn
608
     *
609
     * @return Indi
610
     */
611
    public function setRfn($rfn = '')
612
    {
613
        $this->rfn = $rfn;
614
615
        return $this;
616
    }
617
618
    /**
619
     * @return string
620
     */
621
    public function getRfn()
622
    {
623
        return $this->rfn;
624
    }
625
626
    /**
627
     * @param string $afn
628
     *
629
     * @return Indi
630
     */
631
    public function setAfn($afn = '')
632
    {
633
        $this->afn = $afn;
634
635
        return $this;
636
    }
637
638
    /**
639
     * @return string
640
     */
641
    public function getAfn()
642
    {
643
        return $this->afn;
644
    }
645
646
    /**
647
     * @param string $chan
648
     *
649
     * @return Indi
650
     */
651
    public function setChan($chan = null)
652
    {
653
        $this->chan = $chan;
654
655
        return $this;
656
    }
657
658
    /**
659
     * @return string
660
     */
661
    public function getChan()
662
    {
663
        return $this->chan;
664
    }
665
666
    /**
667
     * @param string $rin
668
     *
669
     * @return Indi
670
     */
671
    public function setRin($rin = '')
672
    {
673
        $this->rin = $rin;
674
675
        return $this;
676
    }
677
678
    /**
679
     * @return string
680
     */
681
    public function getRin()
682
    {
683
        return $this->rin;
684
    }
685
686
    /**
687
     * @param Indi\Bapl $bapl
688
     *
689
     * @return Indi
690
     */
691
    public function setBapl($bapl = [])
692
    {
693
        $this->bapl = $bapl;
0 ignored issues
show
Documentation Bug introduced by
It seems like $bapl can also be of type array. However, the property $bapl is declared as type Gedcom\Record\Indi\Bapl. 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...
694
695
        return $this;
696
    }
697
698
    /**
699
     * @param Indi\Bapl $bapl
700
     *
701
     * @return Indi
702
     */
703
    public function addBapl($bapl = null)
704
    {
705
        $this->bapl[] = $bapl;
706
707
        return $this;
708
    }
709
710
    /**
711
     * @return Indi\Bapl
712
     */
713
    public function getBapl()
714
    {
715
        return $this->bapl;
716
    }
717
718
    /**
719
     * @param Indi\Conl $conl
720
     *
721
     * @return Indi
722
     */
723
    public function setConl($conl = [])
724
    {
725
        $this->conl = $conl;
0 ignored issues
show
Documentation Bug introduced by
It seems like $conl can also be of type array. However, the property $conl is declared as type Gedcom\Record\Indi\Conl. 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...
726
727
        return $this;
728
    }
729
730
    /**
731
     * @param Indi\Conl $conl
732
     *
733
     * @return Indi
734
     */
735
    public function addConl($conl)
736
    {
737
        $this->conl[] = $conl;
738
739
        return $this;
740
    }
741
742
    /**
743
     * @return Indi\Conl
744
     */
745
    public function getConl()
746
    {
747
        return $this->conl;
748
    }
749
750
    /**
751
     * @param Indi\Endl $endl
752
     *
753
     * @return Indi
754
     */
755
    public function setEndl($endl = [])
756
    {
757
        $this->endl = $endl;
0 ignored issues
show
Documentation Bug introduced by
It seems like $endl can also be of type array. However, the property $endl is declared as type Gedcom\Record\Indi\Endl. 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...
758
759
        return $this;
760
    }
761
762
    /**
763
     * @param Indi\Endl $endl
764
     *
765
     * @return Indi
766
     */
767
    public function addEndl($endl)
768
    {
769
        $this->endl[] = $endl;
770
771
        return $this;
772
    }
773
774
    /**
775
     * @return Indi\Endl
776
     */
777
    public function getEndl()
778
    {
779
        return $this->endl;
780
    }
781
782
    /**
783
     * @param Indi\Slgc $slgc
784
     *
785
     * @return Indi
786
     */
787
    public function setSlgc($slgc = [])
788
    {
789
        $this->slgc = $slgc;
0 ignored issues
show
Documentation Bug introduced by
It seems like $slgc can also be of type array. However, the property $slgc is declared as type Gedcom\Record\Indi\Slgc. 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...
790
791
        return $this;
792
    }
793
794
    /**
795
     * @param Indi\Slgc $slgc
796
     *
797
     * @return Indi
798
     */
799
    public function addSlgc($slgc)
800
    {
801
        $this->slgc[] = $slgc;
802
803
        return $this;
804
    }
805
806
    /**
807
     * @return Indi\Slgc
808
     */
809
    public function getSlgc()
810
    {
811
        return $this->slgc;
812
    }
813
}
814