PHP 8.2.31
Preview: ErrorResponse.php Size: 921 B
/home/nshryvcy/himaltourism.com/wp-content/plugins/mailpoet/lib/API/JSON/ErrorResponse.php

<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing

namespace MailPoet\API\JSON;

if (!defined('ABSPATH')) exit;


class ErrorResponse extends Response {
  public $errors;

  public function __construct(
    $errors = [],
    $meta = [],
    $status = self::STATUS_NOT_FOUND
  ) {
    parent::__construct($status, $meta);
    $this->errors = $this->formatErrors($errors);
  }

  public function getData() {
    return (empty($this->errors)) ? null : ['errors' => $this->errors];
  }

  public function formatErrors($errors = []) {
    return array_map(function($error, $message) {
      // sanitize SQL error
      if (preg_match('/^SQLSTATE/i', $message)) {
        $message = __('An unknown error occurred.', 'mailpoet');
      }
      return [
        'error' => $error,
        'message' => $message,
      ];
    }, array_keys($errors), array_values($errors));
  }
}

Directory Contents

Dirs: 2 × Files: 8

Name Size Perms Modified Actions
- drwxr-xr-x 2023-04-04 05:35:40
Edit Download
v1 DIR
- drwxr-xr-x 2023-04-04 05:35:40
Edit Download
9.36 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.49 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
398 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
790 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
921 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
0 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download
1.07 KB lrw-r--r-- 2023-04-04 05:35:40
Edit Download
519 B lrw-r--r-- 2023-04-04 05:35:40
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).