Debian Codegraph @

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

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Jose\Component\Encryption;
6
7 use Jose\Component\Core\AlgorithmManagerFactory;
8 use Jose\Component\Encryption\Compression\CompressionMethodManagerFactory;
9
10 class JWEBuilderFactory
11 {
12 public function __construct(
13 private readonly AlgorithmManagerFactory $algorithmManagerFactory,
14 private readonly null|CompressionMethodManagerFactory $compressionMethodManagerFactory = null
15 ) {
16 if ($compressionMethodManagerFactory !== null) {
17 trigger_deprecation(
18 'web-token/jwt-library',
19 '3.3.0',
20 'The parameter "$compressionMethodManagerFactory" is deprecated and will be removed in 4.0.0. Compression is not recommended for JWE. Please set "null" instead.'
21 );
22 }
23 }
24
25 /**
26 * Creates a JWE Builder object using the given key encryption algorithms, content encryption algorithms and
27 * compression methods.
28 *
29 * @param array<string> $encryptionAlgorithms
30 * @param null|array<string> $contentEncryptionAlgorithm
31 * @param null|string[] $compressionMethods
32 */
33 public function create(
34 array $encryptionAlgorithms,
35 null|array $contentEncryptionAlgorithm = null,
36 null|array $compressionMethods = null
37 ): JWEBuilder {
38 if ($contentEncryptionAlgorithm !== null) {
39 trigger_deprecation(
40 'web-token/jwt-library',
41 '3.3.0',
42 'The parameter "$contentEncryptionAlgorithm" is deprecated and will be removed in 4.0.0. Please set "null" instead.'
43 );
44 $encryptionAlgorithms = array_merge($encryptionAlgorithms, $contentEncryptionAlgorithm);
45 }
46 $encryptionAlgorithmManager = $this->algorithmManagerFactory->create($encryptionAlgorithms);
47 $compressionMethodManager = $compressionMethods === null ? null : $this->compressionMethodManagerFactory?->create(
48 $compressionMethods
49 );
50
51 return new JWEBuilder($encryptionAlgorithmManager, null, $compressionMethodManager);
52 }
53 }