| 1 | <?php |
||
| 18 | abstract class AbstractKey implements KeyInterface |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * The key as a binary data string |
||
| 22 | * |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | private $binKey; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * AbstractKey constructor. |
||
| 29 | * |
||
| 30 | * @param string $binKey The key as a binary data string |
||
| 31 | * |
||
| 32 | * @throws \InvalidArgumentException If the provided key has a wrong size |
||
| 33 | */ |
||
| 34 | 31 | public function __construct($binKey) |
|
| 38 | |||
| 39 | /** |
||
| 40 | * {@inheritdoc} |
||
| 41 | */ |
||
| 42 | 23 | public function toBinary() |
|
| 46 | |||
| 47 | /** |
||
| 48 | * {@inheritdoc} |
||
| 49 | */ |
||
| 50 | 10 | public function toHexadecimal() |
|
| 54 | |||
| 55 | /** |
||
| 56 | * {@inheritdoc} |
||
| 57 | */ |
||
| 58 | 10 | public function __toString() |
|
| 62 | |||
| 63 | /** |
||
| 64 | * Validate the specified key |
||
| 65 | * |
||
| 66 | * @param string $binKey The specified key as a binary data string |
||
| 67 | * |
||
| 68 | * @throws \InvalidArgumentException If the provided key has a wrong size |
||
| 69 | * |
||
| 70 | * @return string Returns the validated key as a binary data string |
||
| 71 | */ |
||
| 72 | abstract protected function validateKey($binKey); |
||
| 73 | } |
||
| 74 |