You are here

public static function UrlData::decode in Commerce Core 8.2

Decodes the given data.

Parameters

string $data: The encoded data.

Return value

array|false The decoded data, or FALSE if decoding failed.

2 calls to UrlData::decode()
TaxNumberController::prepareContext in modules/tax/src/Controller/TaxNumberController.php
Parses and validates the context.
UrlDataTest::testEncodeDecode in tests/src/Unit/UrlDataTest.php
::covers encode ::covers decode.

File

src/UrlData.php, line 36

Class

UrlData
Encodes and decodes array data in a URL-safe way.

Namespace

Drupal\commerce

Code

public static function decode($data) {
  $data = base64_decode(str_replace([
    '-',
    '_',
  ], [
    '+',
    '/',
  ], $data));
  if ($data) {
    $data = json_decode($data, TRUE);
  }
  return is_array($data) ? $data : FALSE;
}