|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace TruckersMP\APIClient\Models; |
| 4 | + |
| 5 | +use Carbon\Carbon; |
| 6 | +use TruckersMP\APIClient\Client; |
| 7 | + |
| 8 | +class PlayerAchievement extends Model |
| 9 | +{ |
| 10 | + /** |
| 11 | + * The ID of the achievement. |
| 12 | + * |
| 13 | + * @var int |
| 14 | + */ |
| 15 | + protected int $id; |
| 16 | + |
| 17 | + /** |
| 18 | + * The title of the achievement. |
| 19 | + * |
| 20 | + * @var string |
| 21 | + */ |
| 22 | + protected string $title; |
| 23 | + |
| 24 | + /** |
| 25 | + * The description of the achievement. |
| 26 | + * |
| 27 | + * @var string |
| 28 | + */ |
| 29 | + protected string $description; |
| 30 | + |
| 31 | + /** |
| 32 | + * The link to the achievement image. |
| 33 | + * |
| 34 | + * @var string |
| 35 | + */ |
| 36 | + protected string $imageUrl; |
| 37 | + |
| 38 | + /** |
| 39 | + * The date and time the user was given the achievement (UTC). |
| 40 | + * |
| 41 | + * @var Carbon |
| 42 | + */ |
| 43 | + protected Carbon $achievedAt; |
| 44 | + |
| 45 | + /** |
| 46 | + * Create a new PlayerAchievement instance. |
| 47 | + * |
| 48 | + * @param Client $client |
| 49 | + * @param array $achievement |
| 50 | + * @return void |
| 51 | + */ |
| 52 | + public function __construct(Client $client, array $achievement) |
| 53 | + { |
| 54 | + parent::__construct($client, $achievement); |
| 55 | + |
| 56 | + $this->id = $this->getValue('id'); |
| 57 | + $this->title = $this->getValue('title'); |
| 58 | + $this->description = $this->getValue('description'); |
| 59 | + $this->imageUrl = $this->getValue('image_url'); |
| 60 | + $this->achievedAt = new Carbon($this->getValue('achieved_at'), 'UTC'); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * Get the ID of the achievement. |
| 65 | + * |
| 66 | + * @return int |
| 67 | + */ |
| 68 | + public function getId(): int |
| 69 | + { |
| 70 | + return $this->id; |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Get the title of the achievement. |
| 75 | + * |
| 76 | + * @return string |
| 77 | + */ |
| 78 | + public function getTitle(): string |
| 79 | + { |
| 80 | + return $this->title; |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * Get the description of the achievement. |
| 85 | + * |
| 86 | + * @return string |
| 87 | + */ |
| 88 | + public function getDescription(): string |
| 89 | + { |
| 90 | + return $this->description; |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * Get the link to the achievement image. |
| 95 | + * |
| 96 | + * @return string |
| 97 | + */ |
| 98 | + public function getImageUrl(): string |
| 99 | + { |
| 100 | + return $this->imageUrl; |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * Get the date and time the user was given the achievement (UTC). |
| 105 | + * |
| 106 | + * @return Carbon |
| 107 | + */ |
| 108 | + public function getAchievedAt(): Carbon |
| 109 | + { |
| 110 | + return $this->achievedAt; |
| 111 | + } |
| 112 | +} |
0 commit comments