- md5
- 6dd0fd1bf7ac0ce7f27b3d6c39a8c9cd
- sha1
- 5a169a1bb7ccbaf542857fe9463cfc7e7d1acb14
- sha256
- 3468d65df048604102fa41de12ce1fbb71cacb42929cf806ee2dcc4101344174
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
<?php
declare(strict_types=1);
namespace Jose\Component\Encryption\Compression;
use InvalidArgumentException;
use function array_key_exists;
/**
* @deprecated This class is deprecated and will be removed in v4.0. Compression is not recommended for JWE.
*/
class CompressionMethodManager
{
/**
* @var CompressionMethod[]
*/
private array $compressionMethods = [];
/**
* @param CompressionMethod[] $methods
*/
public function __construct(iterable $methods = [])
{
foreach ($methods as $method) {
$this->add($method);
}
}
/**
* Returns true if the givn compression method is supported.
*/
public function has(string $name): bool
{
return array_key_exists($name, $this->compressionMethods);
}
/**
* This method returns the compression method with the given name. Throws an exception if the method is not
* supported.
*
* @param string $name The name of the compression method
*/
public function get(string $name): CompressionMethod
{
if (! $this->has($name)) {
throw new InvalidArgumentException(sprintf('The compression method "%s" is not supported.', $name));
}
return $this->compressionMethods[$name];
}
/**
* Returns the list of compression method names supported by the manager.
*
* @return string[]
*/
public function list(): array
{
return array_keys($this->compressionMethods);
}
/**
* Add the given compression method to the manager.
*/
protected function add(CompressionMethod $compressionMethod): void
{
$name = $compressionMethod->name();
$this->compressionMethods[$name] = $compressionMethod;
}
}
The same content is in 118 releases, Joomla 5.2.0-alpha2 to 6.2.1. See them all, or every version of this file.