1 | <?php |
||
18 | class AlgorithmManager |
||
19 | { |
||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | private $algorithms = []; |
||
24 | |||
25 | /** |
||
26 | * @param Algorithm[] $algorithms |
||
27 | */ |
||
28 | public function __construct(array $algorithms) |
||
34 | |||
35 | /** |
||
36 | * Returns true if the algorithm is supported. |
||
37 | * |
||
38 | * @param string $algorithm The algorithm |
||
39 | */ |
||
40 | public function has(string $algorithm): bool |
||
44 | |||
45 | /** |
||
46 | * Returns the list of names of supported algorithms. |
||
47 | * |
||
48 | * @return string[] |
||
49 | */ |
||
50 | public function list(): array |
||
54 | |||
55 | /** |
||
56 | * Returns the algorithm if supported, otherwise throw an exception. |
||
57 | * |
||
58 | * @param string $algorithm The algorithm |
||
59 | * |
||
60 | * @throws InvalidArgumentException if the algorithm is not supported |
||
61 | */ |
||
62 | public function get(string $algorithm): Algorithm |
||
70 | |||
71 | /** |
||
72 | * Adds an algorithm to the manager. |
||
73 | */ |
||
74 | private function add(Algorithm $algorithm): void |
||
79 | } |
||
80 |