You are here

Utility.php in Feeds extensible parsers 7.2

Same filename in this branch
  1. 7.2 src/Json/Utility.php
  2. 7.2 src/Xml/Utility.php
Same filename and directory in other branches
  1. 7 src/Json/Utility.php

Contains FeedsExJsonUtility.

File

src/Json/Utility.php
View source
<?php

/**
 * @file
 * Contains FeedsExJsonUtility.
 */

/**
 * Various helpers for handling JSON.
 */
class FeedsExJsonUtility {

  /**
   * Translates an error message.
   *
   * @param int $error
   *   The JSON error.
   *
   * @return string
   *   The JSON parsing error message.
   */
  public static function translateError($error) {
    switch ($error) {
      case JSON_ERROR_NONE:
        return;
      case JSON_ERROR_DEPTH:
        return 'Maximum stack depth exceeded';
      case JSON_ERROR_STATE_MISMATCH:
        return 'Underflow or the modes mismatch';
      case JSON_ERROR_CTRL_CHAR:
        return 'Unexpected control character found';
      case JSON_ERROR_SYNTAX:
        return 'Syntax error, malformed JSON';
      case JSON_ERROR_UTF8:
        return 'Malformed UTF-8 characters, possibly incorrectly encoded';
      default:
        return 'Unknown error';
    }
  }

}

Classes

Namesort descending Description
FeedsExJsonUtility Various helpers for handling JSON.