Player::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Eekes\VblApi\Entity;
5
6
class Player
7
{
8
    private string $id;
9
    private string $name;
10
    private ?string $membershipNumber;
11
    private ?\DateTimeImmutable $birthDate;
12
    private ?\DateTimeImmutable $affiliationDate;
13
14
    public static function createFromResponse(\stdClass $response): self
15
    {
16
        $player = new self();
17
18
        $player->id = $response->relGuid;
19
        $player->name = $response->naam;
20
        $player->membershipNumber = $response->lidNr;
21
        $player->birthDate = \DateTimeImmutable::createFromFormat('d-m-Y', $response->sGebDat);
22
        $player->affiliationDate = \DateTimeImmutable::createFromFormat('d-m-Y H:i', $response->sAanslDat) ?: null;
23
24
        return $player;
25
    }
26
27
    public function getId(): string
28
    {
29
        return $this->id;
30
    }
31
32
    public function getName(): string
33
    {
34
        return $this->name;
35
    }
36
37
    public function getMembershipNumber(): ?string
38
    {
39
        return $this->membershipNumber;
40
    }
41
42
    public function getBirthDate(): ?\DateTimeImmutable
43
    {
44
        return $this->birthDate;
45
    }
46
47
    public function getAffiliationDate(): ?\DateTimeImmutable
48
    {
49
        return $this->affiliationDate;
50
    }
51
}