-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactored person type entities
- Loading branch information
1 parent
93b053d
commit 30c5e55
Showing
4 changed files
with
162 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Entity; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Util\EntityTrait; | ||
|
||
class Person | ||
{ | ||
use EntityTrait; | ||
|
||
private int $id; | ||
|
||
private int $sportId; | ||
|
||
private ?int $countryId; | ||
|
||
private ?int $cityId; | ||
|
||
private ?string $commonName; | ||
|
||
private ?string $firstName; | ||
|
||
private ?string $lastName; | ||
|
||
private ?string $name; | ||
|
||
private ?string $displayName; | ||
|
||
private ?string $imagePath; | ||
|
||
private ?int $height; | ||
|
||
private ?int $weight; | ||
|
||
private ?\DateTimeImmutable $birthdate; | ||
|
||
private ?string $gender; | ||
|
||
private ?Sport $sport; | ||
|
||
private ?Country $country; | ||
|
||
private ?Country $nationality; | ||
|
||
public function __construct(array $data, string $timezone) | ||
{ | ||
$this->id = $data['id']; | ||
$this->sportId = $data['sport_id']; | ||
$this->countryId = $data['country_id'] ?? null; | ||
$this->cityId = $data['city_id'] ?? null; | ||
|
||
// select | ||
$this->commonName = $data['common_name'] ?? null; | ||
$this->firstName = $data['firstname'] ?? null; | ||
$this->lastName = $data['lastname'] ?? null; | ||
$this->name = $data['name'] ?? null; | ||
$this->displayName = $data['display_name'] ?? null; | ||
$this->imagePath = $data['image_path'] ?? null; | ||
$this->height = $data['height'] ?? null; | ||
$this->weight = $data['weight'] ?? null; | ||
$this->birthdate = isset($data['date_of_birth']) ? new \DateTimeImmutable($data['date_of_birth']) : null; | ||
$this->gender = $data['gender'] ?? null; | ||
|
||
// include | ||
$this->sport = isset($data['sport']) ? new Sport($data['sport']) : null; | ||
$this->country = isset($data['country']) ? new Country($data['country'], $timezone) : null; | ||
$this->nationality = isset($data['nationality']) ? new Country($data['nationality'], $timezone) : null; | ||
} | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getSportId(): int | ||
{ | ||
return $this->sportId; | ||
} | ||
|
||
public function getCountryId(): ?int | ||
{ | ||
return $this->countryId; | ||
} | ||
|
||
public function getCityId(): ?int | ||
{ | ||
return $this->cityId; | ||
} | ||
|
||
public function getCommonName(): ?string | ||
{ | ||
return $this->commonName; | ||
} | ||
|
||
public function getFirstName(): ?string | ||
{ | ||
return $this->firstName; | ||
} | ||
|
||
public function getLastName(): ?string | ||
{ | ||
return $this->lastName; | ||
} | ||
|
||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function getDisplayName(): ?string | ||
{ | ||
return $this->displayName; | ||
} | ||
|
||
public function getImagePath(): ?string | ||
{ | ||
return $this->imagePath; | ||
} | ||
|
||
public function getHeight(): ?int | ||
{ | ||
return $this->height; | ||
} | ||
|
||
public function getWeight(): ?int | ||
{ | ||
return $this->weight; | ||
} | ||
|
||
public function getBirthdate(): ?\DateTimeImmutable | ||
{ | ||
return $this->birthdate; | ||
} | ||
|
||
public function getGender(): ?string | ||
{ | ||
return $this->gender; | ||
} | ||
|
||
public function getSport(): ?Sport | ||
{ | ||
return $this->sport; | ||
} | ||
|
||
public function getCountry(): ?Country | ||
{ | ||
return $this->country; | ||
} | ||
|
||
public function getNationality(): ?Country | ||
{ | ||
return $this->nationality; | ||
} | ||
} |
Oops, something went wrong.