XOOPS  2.6.0
Response.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
12 namespace Xoops\Core\Service;
13 
30 class Response
31 {
33  protected $value = null;
34 
36  protected $success = true;
37 
39  protected $errorMessage = null;
40 
50  public function __constructor($value = null, $success = true, $errorMessage = null)
51  {
52  $this->value = $value;
53  $this->success = $success;
54  if ($errorMessage!==null) {
56  }
57  }
58 
64  public function getValue()
65  {
66  return $this->value;
67  }
68 
74  public function isSuccess()
75  {
76  return $this->success;
77  }
78 
84  public function getErrorMessage()
85  {
86  return $this->errorMessage;
87  }
88 
96  public function setValue($value)
97  {
98  $this->value = $value;
99 
100  return $this;
101  }
102 
110  public function setSuccess($success)
111  {
112  $this->success = $success;
113 
114  return $this;
115  }
116 
125  {
126  $ret = array();
127  if (is_array($this->errorMessage)) {
128  $ret = $this->errorMessage;
129  } elseif (is_scalar($this->errorMessage)) {
130  $ret[] = $this->errorMessage;
131  }
132  if (is_array($errorMessage)) {
133  $ret = array_merge($ret, $errorMessage);
134  } elseif (is_scalar($errorMessage)) {
135  $ret[] = $errorMessage;
136  }
137 
138  $this->errorMessage = $ret;
139 
140  return $this;
141  }
142 }
addErrorMessage($errorMessage)
Definition: Response.php:124
__constructor($value=null, $success=true, $errorMessage=null)
Definition: Response.php:50