@param \stdClass $error
@param array     $content

@return string
345452
protected function formatXmlError(\stdClass $error, array $content)
    {
        $return = '';

        if (array_key_exists($error->line - 1, $content)) {
            $return .= $content[ $error->line - 1 ] . "\n";
            $return .= str_repeat('-', $error->column) . "^\n";
        }

        switch ($error->level) {
            case LIBXML_ERR_WARNING:
                $return .= "Warning $error->code: ";
                break;
            case LIBXML_ERR_ERROR:
                $return .= "Error $error->code: ";
                break;
            case LIBXML_ERR_FATAL:
                $return .= "Fatal Error $error->code: ";
                break;
        }

        $return .= trim($error->message) . "\n  Line: $error->line" . "\n  Column: $error->column";

        return $return;
    }
780142
public function renderText($content, $data = [])
    {
        if (!$content) {
            return '';
        }

        $text = $this->renderTwig($content, $data);

        $text = html_entity_decode(preg_replace("/[\r\n]{2,}/", "\n\n", $text), ENT_QUOTES, 'UTF-8');

        return $text;
    }
278107
private function createEventFromResponseContent(array $content): Event
    {
        $type = $content['eventType'];
        $version = (int) $content['eventNumber'];
        $data = $content['data'];
        $metadata = (!empty($content['metadata'])) ? $content['metadata'] : null;
        $eventId = (!empty($content['eventId']) ? UUID::fromNative($content['eventId']) : null);

        return new Event($type, $version, $data, $metadata, $eventId);
    }
475307
public static function error_to_string( $errors ) {
		if ( is_string( $errors ) ) {
			return $errors;
		}

		// Only json_encode() the data when it needs it
		$render_data = function( $data ) {
			if ( is_array( $data ) || is_object( $data ) ) {
				return json_encode( $data );
			}

			return '"' . $data . '"';
		};

		if ( is_object( $errors ) && is_a( $errors, 'WP_Error' ) ) {
			foreach ( $errors->get_error_messages() as $message ) {
				if ( $errors->get_error_data() ) {
					return $message . ' ' . $render_data( $errors->get_error_data() );
				}

				return $message;
			}
		}
	}
658516
protected function ajaxContent($content)
    {
        $message = null;

        $this->header('Content-Type', 'application/json');

        if ($content instanceof Arrayable) {
            $content = $content->toArray();
        } elseif (is_string($content)) {
            $content = ['content' => $content];
        } elseif (!is_array($content) && !$content instanceof \Exception) {
            return $this->ajaxContent(new \Exception("No valid content has been submitted!", BaseResponse::HTTP_BAD_REQUEST));
        } elseif ($content instanceof \Exception) {

            $this->setStatusCode($content->getCode() < 300 ? BaseResponse::HTTP_BAD_REQUEST : $content->getCode());

            $message = $content->getMessage();

            if ($content instanceof MbException) {
                $content = $content->getMessages();
            } else {
                $content = null;
            }
        }

        $this->original = [
            'meta' => [
                'code'    => $this->getStatusCode(),
                'message' => $message,
            ],
            'data' => $content,
        ];

        $this->getMbAudit()->setResponseType('ajax');
        $this->getMbAudit()->setResponseData($this->original);

        return $this->original;
    }
1117773
private static function applicationErrorToException($error) {
    switch($error->getApplicationError()) {
      case ErrorCode::URL_TOO_LONG:
        $result = new \InvalidArgumentException(
            'The upload URL supplied was too long.');
        break;
      case ErrorCode::PERMISSION_DENIED:
        $result = new CloudStorageException('Permission Denied');
        break;
      case ErrorCode::ARGUMENT_OUT_OF_RANGE:
        $result = new \InvalidArgumentException($error->getMessage());
        break;
      default:
        $result = new CloudStorageException(
            'Error Code: ' . $error->getApplicationError());
    }
    return $result;
  }
933574
public function fromArray(array $error)
    {

        // extract the array with the error information
        list ($type, $message, $file, $line) = array_values($error);

        // initialize and return the error instance
        return new Error($type, $message, $file, $line, ErrorUtil::singleton()->isFatal($type) ? 500 : 0);
    }
90515
public function error($title, $content, $icon = true, $iconSmall = true)
    {
        $this->message('danger', $title, $content, $icon, $iconSmall);
    }
151977
protected function string($content)
    {
        // Check if not is string ...
        if (false === is_string($content)) {
            // ... and make string of it.
            $content = var_export($content, true);
        }

        return $content;
    }
1005593
public function sanitizeInput(string $content):string{
		return htmlspecialchars($content, ENT_NOQUOTES | ENT_SUBSTITUTE | ENT_DISALLOWED | ENT_HTML5, 'UTF-8', false);
	}
1184342
public function renderErrors($errors)
    {
        if (empty($errors)) {
            return null;
        }

        $message = '';

        foreach ($errors as &$error) {
            foreach ($error as $errorCode => &$errorMsg) {
                $message .= $this->errorMapper($errorCode, $errorMsg);
            }
        }

        return $message;
    }
328823
public function render ($content = null)
		{
			// Custom error output.
			$errors = $this->model->getErrors($this->attribute);

			if (count($errors) == 0)
				$this->parts[ '{error}' ] = '';
			else
			{
				$class = isset($this->errorOptions[ 'class' ]) ? ' class="' . $this->errorOptions[ 'class' ] . '"' : '';
				$this->parts[ '{error}' ] = '<div' . $class . '><ul class="list-unstyled">';
				foreach ($errors as $e)
				{
					$this->parts[ '{error}' ] .= '<li>' . $e . '</li>';
				}
				$this->parts[ '{error}' ] .= '</ul></div>';
			}

			return parent::render($content);
		}
1267481
public function display_error($error = '', $swap = '', $native = false)
    {
        if (is_array($error)) {
            $error = implode('; ', $error);
        }
        throw new QueryException($error);
    }
560629
protected function detectFormatByContent($content)
    {
        if (preg_match('/^(\\{|\\[\\{).*(\\}|\\}\\])$/is', $content)) {
            return Client::FORMAT_JSON;
        }
        if (preg_match('/^([^=&])+=[^=&]+(&[^=&]+=[^=&]+)*$/', $content)) {
            return Client::FORMAT_URLENCODED;
        }
        if (preg_match('/^<\?xml.*>$/s', $content)) {
            return Client::FORMAT_XML;
        }
        return null;
    }
1005855
public static function markupToPHP($content) 
    {
        if ($content instanceof phpQueryObject) {
            $content = $content->markupOuter();
        }
        /* <php>...</php> to <?php...? > */
        $content = preg_replace_callback(
            '@<php>\s*<!--(.*?)-->\s*</php>@s',
            //            create_function('$m',
            //                'return "<'.'?php ".htmlspecialchars_decode($m[1])." ?'.'>";'
            //            ),
            array('phpQuery', '_markupToPHPCallback'),
            $content
        );
        /* <node attr='< ?php ? >'> extra space added to save highlighters */
        $regexes = array(
        '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(\')([^\']*)(?:&lt;|%3C)\\?(?:php)?(.*?)(?:\\?(?:&gt;|%3E))([^\']*)\'@s',
        '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(")([^"]*)(?:&lt;|%3C)\\?(?:php)?(.*?)(?:\\?(?:&gt;|%3E))([^"]*)"@s',
        );
        foreach($regexes as $regex) {
            while (preg_match($regex, $content)) {
                $content = preg_replace_callback(
                    $regex,
                    create_function(
                        '$m',
                        'return $m[1].$m[2].$m[3]."<?php "
							.str_replace(
								array("%20", "%3E", "%09", "&#10;", "&#9;", "%7B", "%24", "%7D", "%22", "%5B", "%5D"),
								array(" ", ">", "	", "\n", "	", "{", "$", "}", \'"\', "[", "]"),
								htmlspecialchars_decode($m[4])
							)
							." ?>".$m[5].$m[2];'
                    ),
                    $content
                );
            }
        }
        return $content;
    }
1215679
public function getErrorMessage($error)
    {
        $jsonResponse = json_decode($error->getResponse()->getBody(), true);
        $errorMessage = $error->getMessage();

        if (count($jsonResponse['errors']) > 0) {
            $errorMessage = $jsonResponse['errors'][0]['message'];
        }

        return $errorMessage;
    }
104421
protected function createErrorResponse($content = 'Unknown Error', $code = 500)
    {
        $data = [
            'message' => $content
        ];

        $response = $this->createJsonResponse($data, $code);
        return $response;
    }