Debian Codegraph @

lib/3rdParty/composer/web-token/jwt-library/Encryption/Recipient.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Jose\Component\Encryption;
6
7 use InvalidArgumentException;
8 use function array_key_exists;
9
10 /**
11 * @internal
12 */
13 final class Recipient
14 {
15 public function __construct(
16 private readonly array $header,
17 private readonly ?string $encryptedKey
18 ) {
19 }
20
21 /**
22 * Returns the recipient header.
23 */
24 public function getHeader(): array
25 {
26 return $this->header;
27 }
28
29 /**
30 * Returns the value of the recipient header parameter with the specified key.
31 *
32 * @param string $key The key
33 *
34 * @return mixed|null
35 */
36 public function getHeaderParameter(string $key)
37 {
38 if (! $this->hasHeaderParameter($key)) {
39 throw new InvalidArgumentException(sprintf('The header "%s" does not exist.', $key));
40 }
41
42 return $this->header[$key];
43 }
44
45 /**
46 * Returns true if the recipient header contains the parameter with the specified key.
47 *
48 * @param string $key The key
49 */
50 public function hasHeaderParameter(string $key): bool
51 {
52 return array_key_exists($key, $this->header);
53 }
54
55 /**
56 * Returns the encrypted key.
57 */
58 public function getEncryptedKey(): ?string
59 {
60 return $this->encryptedKey;
61 }
62 }