friendship ended with social-app. php is my new best friend
at main 676 B view raw
1<?php 2declare(strict_types=1); 3 4namespace Lcobucci\JWT\Encoding; 5 6use Lcobucci\JWT\ClaimsFormatter; 7use Lcobucci\JWT\Token\RegisteredClaims; 8 9use function array_key_exists; 10use function count; 11use function current; 12 13final class UnifyAudience implements ClaimsFormatter 14{ 15 /** @inheritdoc */ 16 public function formatClaims(array $claims): array 17 { 18 if ( 19 ! array_key_exists(RegisteredClaims::AUDIENCE, $claims) 20 || count($claims[RegisteredClaims::AUDIENCE]) !== 1 21 ) { 22 return $claims; 23 } 24 25 $claims[RegisteredClaims::AUDIENCE] = current($claims[RegisteredClaims::AUDIENCE]); 26 27 return $claims; 28 } 29}