- md5
- 9e17f65689d7926bde6b5b629da357ec
- sha1
- b805e2b72e3fa4ebc052d52ec1792d5aef27a13a
- sha256
- 0654d3461eef2ebadd8e42992696edffb5aaa985140a03fba5181b048bff9606
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
<?php
declare(strict_types=1);
namespace Jose\Component\Encryption\Compression;
use InvalidArgumentException;
use function array_key_exists;
class CompressionMethodManager
{
/**
* @var CompressionMethod[]
*/
private array $compressionMethods = [];
public function __construct(array $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 17 releases, Joomla 5.1.0-beta1 to 5.2.0-alpha1. See them all, or every version of this file.