diff --git a/src/JWT.php b/src/JWT.php index 4de393c..cc02eb2 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -211,4 +211,15 @@ private static function b64encode(array $data): string } return rtrim(strtr(base64_encode($json), '+/', '-_'), '='); } // b64encode + + public function __debugInfo(): array + { + return [ + 'headers' => $this->headers, + 'claims' => $this->claims, + 'signature' => isset($this->signature) ? $this->signature : '(not signed)', + 'verified' => $this->is_verified, + 'keyContainer' => isset($this->keys) ? '(set)' : '(not set)', + ]; + } } diff --git a/src/KeyContainer.php b/src/KeyContainer.php index a65412b..d582b92 100644 --- a/src/KeyContainer.php +++ b/src/KeyContainer.php @@ -52,4 +52,14 @@ public function getKey($id = null): array list($alg, $secret) = $this->keys[$id]; return [$alg, $secret, $id]; } + + public function __debugInfo(): array + { + return [ + 'keys' => array_values(array_map(function ($keyInfo, $id) { + return ['id' => $id, 'alg' => $keyInfo[0]]; + }, $this->keys, array_keys($this->keys))), + 'default' => $this->default, + ]; + } }