Download.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\License\DataTransferObjects; |
| 4 | |
| 5 | /** |
| 6 | * @since 4.3.0 |
| 7 | */ |
| 8 | class Download |
| 9 | { |
| 10 | public int $index; |
| 11 | public int $attachmentId; |
| 12 | public string $thumbnailSize; |
| 13 | public string $name; |
| 14 | public string $file; |
| 15 | public string $condition; |
| 16 | public int $arrayIndex; |
| 17 | public string $pluginSlug; |
| 18 | public string $readme; |
| 19 | public string $currentVersion; |
| 20 | |
| 21 | /** |
| 22 | * @since 4.3.0 |
| 23 | */ |
| 24 | public static function fromData(array $data): self |
| 25 | { |
| 26 | $self = new self(); |
| 27 | $self->index = (int)($data['index'] ?? 0); |
| 28 | $self->attachmentId = (int)($data['attachment_id'] ?? 0); |
| 29 | $self->thumbnailSize = (string)($data['thumbnail_size'] ?? 'thumbnail'); |
| 30 | $self->name = (string)($data['name'] ?? ''); |
| 31 | $self->file = (string)($data['file'] ?? ''); |
| 32 | $self->condition = (string)($data['condition'] ?? ''); |
| 33 | $self->arrayIndex = (int)($data['array_index'] ?? 0); |
| 34 | $self->pluginSlug = (string)($data['plugin_slug'] ?? ''); |
| 35 | $self->readme = (string)($data['readme'] ?? ''); |
| 36 | $self->currentVersion = (string)($data['current_version'] ?? ''); |
| 37 | |
| 38 | return $self; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 |