commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
ErrorResponseModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
17 use stdClass;
18 
22 final class ErrorResponseModel extends JsonObjectModel implements ErrorResponse
23 {
28  protected $statusCode;
29 
34  protected $message;
35 
40  protected $errors;
41 
42 
46  public function __construct(
47  ?int $statusCode = null,
48  ?string $message = null,
50  ) {
51  $this->statusCode = $statusCode;
52  $this->message = $message;
53  $this->errors = $errors;
54  }
55 
62  public function getStatusCode()
63  {
64  if (is_null($this->statusCode)) {
66  $data = $this->raw(self::FIELD_STATUS_CODE);
67  if (is_null($data)) {
68  return null;
69  }
70  $this->statusCode = (int) $data;
71  }
72 
73  return $this->statusCode;
74  }
75 
82  public function getMessage()
83  {
84  if (is_null($this->message)) {
86  $data = $this->raw(self::FIELD_MESSAGE);
87  if (is_null($data)) {
88  return null;
89  }
90  $this->message = (string) $data;
91  }
92 
93  return $this->message;
94  }
95 
103  public function getErrors()
104  {
105  if (is_null($this->errors)) {
107  $data = $this->raw(self::FIELD_ERRORS);
108  if (is_null($data)) {
109  return null;
110  }
111  $this->errors = ErrorObjectCollection::fromArray($data);
112  }
113 
114  return $this->errors;
115  }
116 
117 
121  public function setStatusCode(?int $statusCode): void
122  {
123  $this->statusCode = $statusCode;
124  }
125 
129  public function setMessage(?string $message): void
130  {
131  $this->message = $message;
132  }
133 
137  public function setErrors(?ErrorObjectCollection $errors): void
138  {
139  $this->errors = $errors;
140  }
141 }
__construct(?int $statusCode=null, ?string $message=null, ?ErrorObjectCollection $errors=null)