$data JSON data * @return self */ public static function fromArray(array $data): self { $dest = new self(); $dest->type = $data['type']; $dest->left = $data['left'] ?? null; $dest->top = $data['top'] ?? null; $dest->right = $data['right'] ?? null; $dest->bottom = $data['bottom'] ?? null; $dest->zoom = $data['zoom'] ?? null; return $dest; } /** * Convert to JSON array * * @return array */ public function toArray(): array { $data = [ 'type' => $this->type, ]; if ($this->left !== null) { $data['left'] = $this->left; } if ($this->top !== null) { $data['top'] = $this->top; } if ($this->right !== null) { $data['right'] = $this->right; } if ($this->bottom !== null) { $data['bottom'] = $this->bottom; } if ($this->zoom !== null) { $data['zoom'] = $this->zoom; } return $data; } }