[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * This file is part of Lcobucci\JWT, a simple library to handle JWT and JWS 4 * 5 * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause 6 */ 7 8 namespace Lcobucci\JWT\Parsing; 9 10 use JsonException; 11 use Lcobucci\JWT\Encoding\CannotDecodeContent; 12 use RuntimeException; 13 14 use function json_decode; 15 use function json_last_error; 16 use function json_last_error_msg; 17 18 /** 19 * Class that decodes data according with the specs of RFC-4648 20 * 21 * @author Luís Otávio Cobucci Oblonczyk <[email protected]> 22 * @since 0.1.0 23 * 24 * @link http://tools.ietf.org/html/rfc4648#section-5 25 */ 26 class Decoder 27 { 28 /** 29 * Decodes from JSON, validating the errors (will return an associative array 30 * instead of objects) 31 * 32 * @param string $json 33 * @return mixed 34 * 35 * @throws RuntimeException When something goes wrong while decoding 36 */ 37 public function jsonDecode($json) 38 { 39 if (PHP_VERSION_ID < 70300) { 40 $data = json_decode($json); 41 42 if (json_last_error() != JSON_ERROR_NONE) { 43 throw CannotDecodeContent::jsonIssues(new JsonException(json_last_error_msg())); 44 } 45 46 return $data; 47 } 48 49 try { 50 return json_decode($json, false, 512, JSON_THROW_ON_ERROR); 51 } catch (JsonException $exception) { 52 throw CannotDecodeContent::jsonIssues($exception); 53 } 54 } 55 56 /** 57 * Decodes from base64url 58 * 59 * @param string $data 60 * @return string 61 */ 62 public function base64UrlDecode($data) 63 { 64 if ($remainder = strlen($data) % 4) { 65 $data .= str_repeat('=', 4 - $remainder); 66 } 67 68 return base64_decode(strtr($data, '-_', '+/')); 69 } 70 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |