| Total Complexity | 10 |
| Total Lines | 82 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | class TexturesPropertyValue { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * @var string |
||
| 10 | */ |
||
| 11 | private $id; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | private $username; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var array |
||
| 20 | */ |
||
| 21 | private $textures; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var int |
||
| 25 | */ |
||
| 26 | private $timestamp; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var bool |
||
| 30 | */ |
||
| 31 | private $signatureRequired; |
||
| 32 | |||
| 33 | 4 | public function __construct( |
|
| 34 | string $profileId, |
||
| 35 | string $profileName, |
||
| 36 | array $textures, |
||
| 37 | int $timestamp, |
||
| 38 | bool $signatureRequired = false |
||
| 39 | ) { |
||
| 40 | 4 | $this->id = $profileId; |
|
| 41 | 4 | $this->username = $profileName; |
|
| 42 | 4 | $this->textures = $textures; |
|
| 43 | 4 | $this->timestamp = (int)floor($timestamp / 1000); |
|
| 44 | 4 | $this->signatureRequired = $signatureRequired; |
|
| 45 | 4 | } |
|
| 46 | |||
| 47 | 2 | public static function createFromRawTextures(string $rawTextures): self { |
|
| 48 | 2 | $decoded = json_decode(base64_decode($rawTextures), true); |
|
| 49 | 2 | return new static( |
|
| 50 | 2 | $decoded['profileId'], |
|
| 51 | 2 | $decoded['profileName'], |
|
| 52 | 2 | $decoded['textures'], |
|
| 53 | 2 | $decoded['timestamp'], |
|
| 54 | 2 | $decoded['signatureRequired'] ?? false |
|
| 55 | ); |
||
| 56 | } |
||
| 57 | |||
| 58 | 2 | public function getProfileId(): string { |
|
| 59 | 2 | return $this->id; |
|
| 60 | } |
||
| 61 | |||
| 62 | 2 | public function getProfileName(): string { |
|
| 63 | 2 | return $this->username; |
|
| 64 | } |
||
| 65 | |||
| 66 | 2 | public function getTimestamp(): int { |
|
| 68 | } |
||
| 69 | |||
| 70 | 2 | public function isSignatureRequired(): bool { |
|
| 72 | } |
||
| 73 | |||
| 74 | 3 | public function getSkin(): ?TexturesPropertyValueSkin { |
|
| 75 | 3 | if (!isset($this->textures['SKIN'])) { |
|
| 76 | 1 | return null; |
|
| 77 | } |
||
| 78 | |||
| 79 | 3 | return TexturesPropertyValueSkin::createFromTextures($this->textures['SKIN']); |
|
| 80 | } |
||
| 81 | |||
| 82 | 3 | public function getCape(): ?TexturesPropertyValueCape { |
|
| 88 | } |
||
| 89 | |||
| 90 | } |
||
| 91 |