69 public static function newFatal( $message, ...$parameters ) {
70 $result =
new static();
71 $result->fatal( $message, ...$parameters );
82 $result =
new static();
99 $errorsOnlyStatusValue = clone $this;
100 $warningsOnlyStatusValue = clone $this;
101 $warningsOnlyStatusValue->ok =
true;
103 $errorsOnlyStatusValue->errors = $warningsOnlyStatusValue->errors = [];
104 foreach ( $this->errors as $item ) {
105 if ( $item[
'type'] ===
'warning' ) {
106 $warningsOnlyStatusValue->errors[] = $item;
108 $errorsOnlyStatusValue->errors[] = $item;
112 return [ $errorsOnlyStatusValue, $warningsOnlyStatusValue ];
168 $this->ok = (bool)
$ok;
178 public function warning( $message, ...$parameters ) {
181 'message' => $message,
182 'params' => $parameters
193 public function error( $message, ...$parameters ) {
196 'message' => $message,
197 'params' => $parameters
208 public function fatal( $message, ...$parameters ) {
211 'message' => $message,
212 'params' => $parameters
223 public function merge( $other, $overwriteValue =
false ) {
224 $this->errors = array_merge( $this->errors, $other->errors );
225 $this->ok = $this->ok && $other->ok;
226 if ( $overwriteValue ) {
227 $this->
value = $other->value;
229 $this->successCount += $other->successCount;
230 $this->failCount += $other->failCount;
245 foreach ( $this->errors as $error ) {
246 if ( $error[
'type'] ===
$type ) {
263 $message = $message->getKey();
265 foreach ( $this->errors as $error ) {
267 && $error[
'message']->getKey() === $message
270 } elseif ( $error[
'message'] === $message ) {
292 foreach ( $this->errors as $index => $error ) {
293 if ( $error[
'message'] ===
$source ) {
294 $this->errors[$index][
'message'] = $dest;
307 if ( count( $this->errors ) ) {
308 $errorcount =
"collected " . ( count( $this->errors ) ) .
" error(s) on the way";
310 $errorcount =
"no errors detected";
312 if ( isset( $this->
value ) ) {
313 $valstr = gettype( $this->
value ) .
" value set";
314 if ( is_object( $this->
value ) ) {
315 $valstr .=
"\"" . get_class( $this->
value ) .
"\" instance";
318 $valstr =
"no value set";
320 $out = sprintf(
"<%s, %s, %s>",
325 if ( count( $this->errors ) > 0 ) {
326 $hdr = sprintf(
"+-%'-4s-+-%'-25s-+-%'-40s-+\n",
"",
"",
"" );
330 foreach ( $this->errors as $error ) {
332 $key = $error[
'message']->getKey();
333 $params = $error[
'message']->getParams();
334 } elseif ( $error[
'params'] ) {
335 $key = $error[
'message'];
336 $params = $error[
'params'];
338 $key = $error[
'message'];
342 $out .= sprintf(
"| %4d | %-25.25s | %-40.40s |\n",
345 implode(
" ", $params )