You are here

public static function Inline::evaluateBinaryScalar in Lockr 7.3

@internal

Parameters

string $scalar:

Return value

string

2 calls to Inline::evaluateBinaryScalar()
Inline::evaluateScalar in vendor/symfony/yaml/Inline.php
Evaluates scalars and replaces magic values.
Parser::parseValue in vendor/symfony/yaml/Parser.php
Parses a YAML value.

File

vendor/symfony/yaml/Inline.php, line 834

Class

Inline
Inline implements a YAML parser/dumper for the YAML inline syntax.

Namespace

Symfony\Component\Yaml

Code

public static function evaluateBinaryScalar($scalar) {
  $parsedBinaryData = self::parseScalar(preg_replace('/\\s/', '', $scalar));
  if (0 !== \strlen($parsedBinaryData) % 4) {
    throw new ParseException(sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', \strlen($parsedBinaryData)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
  }
  if (!Parser::preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) {
    throw new ParseException(sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
  }
  return base64_decode($parsedBinaryData, true);
}