Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
RestError.php
Go to the documentation of this file.
1<?php
2
4
5class RestError {
6 private $status;
7 private $code;
8 private $source;
9 private $title;
10 private $detail;
11
12 public function __construct($code, $title, $detail = null, $source = null, $status = null) {
13 $this->code = $code;
14 $this->title = $title;
15 $this->detail = $detail;
16 $this->source = $source;
17 $this->status = $status;
18 }
19
24 public function getStatus() {
25 return $this->status;
26 }
27
32 public function getCode() {
33 return $this->code;
34 }
35
40 public function getSource() {
41 return $this->source;
42 }
43
48 public function getTitle() {
49 return $this->title;
50 }
51
56 public function getDetail() {
57 return $this->detail;
58 }
59
64 public function setStatus($status) {
65 $this->status = $status;
66 }
67
72 public function setCode($code) {
73 $this->code = $code;
74 }
75
80 public function setSource($source) {
81 $this->source = $source;
82 }
83
88 public function setTitle($title) {
89 $this->title = $title;
90 }
91
96 public function setDetail($detail) {
97 $this->detail = $detail;
98 }
99
100 public function asArray() {
101 $r = [ ];
102 if (isset ( $this->code )) {
103 $r ['code'] = $this->code;
104 }
105 if (isset ( $this->status )) {
106 $r ['status'] = $this->status;
107 }
108 if (isset ( $this->source )) {
109 $r ['source'] = [ 'pointer' => $this->source ];
110 }
111 if (isset ( $this->title )) {
112 $r ['title'] = $this->title;
113 }
114 if (isset ( $this->detail )) {
115 $r ['detail'] = $this->detail;
116 }
117 return $r;
118 }
119
120 public static function notFound($keyValues,$source=null){
121 return new RestError(404, "No result found","No result found for primary key(s): ".$keyValues,$source,404);
122 }
123}
124
__construct($code, $title, $detail=null, $source=null, $status=null)
Definition RestError.php:12
static notFound($keyValues, $source=null)