<?php
 declare(strict_types=1); namespace Square\Models; use stdClass; class Error implements \JsonSerializable { private $category; private $code; private $detail; private $field; public function __construct(string $category, string $code) { $this->category = $category; $this->code = $code; } public function getCategory(): string { return $this->category; } public function setCategory(string $category): void { $this->category = $category; } public function getCode(): string { return $this->code; } public function setCode(string $code): void { $this->code = $code; } public function getDetail(): ?string { return $this->detail; } public function setDetail(?string $detail): void { $this->detail = $detail; } public function getField(): ?string { return $this->field; } public function setField(?string $field): void { $this->field = $field; } #[\ReturnTypeWillChange] public function jsonSerialize(bool $asArrayWhenEmpty = false) { $json = []; $json['category'] = $this->category; $json['code'] = $this->code; if (isset($this->detail)) { $json['detail'] = $this->detail; } if (isset($this->field)) { $json['field'] = $this->field; } $json = array_filter($json, function ($val) { return $val !== null; }); return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; } } 