+ /**
+ * Splits this StatusValue object into two new StatusValue objects, one which contains only
+ * the error messages, and one that contains the warnings, only. The returned array is
+ * defined as:
+ * [
+ * 0 => object(StatusValue) # the StatusValue with error messages, only
+ * 1 => object(StatusValue) # The StatusValue with warning messages, only
+ * ]
+ *
+ * @return StatusValue[]
+ */
+ public function splitByErrorType() {
+ $errorsOnlyStatusValue = clone $this;
+ $warningsOnlyStatusValue = clone $this;
+ $warningsOnlyStatusValue->ok = true;
+
+ $errorsOnlyStatusValue->errors = $warningsOnlyStatusValue->errors = [];
+ foreach ( $this->errors as $item ) {
+ if ( $item['type'] === 'warning' ) {
+ $warningsOnlyStatusValue->errors[] = $item;
+ } else {
+ $errorsOnlyStatusValue->errors[] = $item;
+ }
+ };
+
+ return [ $errorsOnlyStatusValue, $warningsOnlyStatusValue ];
+ }
+