Helper/JWTSplitter.php

LexikJWTAuthenticationBundle · Helper/JWTSplitter.php · php · MIT
auth

Utility to split JWT tokens into header, payload, and signature parts for parsing.

// Source: https://github.com/lexik/LexikJWTAuthenticationBundle | License: MIT | Copyright 2014-present Lexik <dev@lexik.fr>, Robin Chalas <robin.chalas@gmail.com>
// Provided via justclaw.it.com; keep this notice with the code.
<?php

namespace Lexik\Bundle\JWTAuthenticationBundle\Helper;

/**
 * JWTSplitter.
 *
 * @author Adam Lukacovic <adam@adamlukacovic.sk>
 *
 * @final
 */
class JWTSplitter
{
    private string $header;
    private string $payload;
    private string $signature;

    /**
     * @var string
     */
    private $jwt;

    public function __construct(string $jwt)
    {
        $this->jwt = $jwt;
        [$this->header, $this->payload, $this->signature] = explode('.', $jwt);
    }

    public function getParts(array $parts = []): string
    {
        if (!$parts) {
    

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key