$data JSON data * @return self */ public static function fromArray(array $data): self { $attachment = new self(); $attachment->name = $data['name']; $attachment->description = $data['description'] ?? null; $attachment->mime_type = $data['mime_type'] ?? null; $attachment->size = $data['size']; $attachment->created = $data['created'] ?? null; $attachment->modified = $data['modified'] ?? null; $attachment->checksum_md5 = $data['checksum_md5'] ?? null; $attachment->data = $data['data'] ?? null; $attachment->truncated = $data['truncated'] ?? false; return $attachment; } /** * Convert to JSON array * * @return array */ public function toArray(): array { $data = [ 'name' => $this->name, 'size' => $this->size, 'truncated' => $this->truncated, ]; if ($this->description !== null) { $data['description'] = $this->description; } if ($this->mime_type !== null) { $data['mime_type'] = $this->mime_type; } if ($this->created !== null) { $data['created'] = $this->created; } if ($this->modified !== null) { $data['modified'] = $this->modified; } if ($this->checksum_md5 !== null) { $data['checksum_md5'] = $this->checksum_md5; } if ($this->data !== null) { $data['data'] = $this->data; } return $data; } }