Completed
Push — master ( d3ed9f...edab03 )
by Tony Karavasilev (Тони
07:44
created

DigestionKeyTrait::getKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * Trait implementation of the keyed hashing capabilities for digestion algorithms.
5
 */
6
7
namespace CryptoManana\Core\Traits\MessageDigestion;
8
9
use \CryptoManana\Core\Interfaces\MessageDigestion\DigestionKeyInterface as DigestionKeySpecification;
10
11
/**
12
 * Trait DigestionKeyTrait - Reusable implementation of `DigestionKeyInterface`.
13
 *
14
 * @see \CryptoManana\Core\Interfaces\MessageDigestion\DigestionKeyInterface The abstract specification.
15
 *
16
 * @package CryptoManana\Core\Traits\MessageDigestion
17
 *
18
 * @property string $key The key string property storage.
19
 *
20
 * @mixin DigestionKeySpecification
21
 */
22
trait DigestionKeyTrait
23
{
24
    /**
25
     * Setter for the key string property.
26
     *
27
     * @param string $key The digestion key string.
28
     *
29
     * @return $this The hash algorithm object.
30
     * @throw \Exception Validation errors.
31
     */
32 154
    public function setKey($key)
33
    {
34 154
        if (!is_string($key)) {
35 22
            throw new \InvalidArgumentException('The key must be of type string.');
36
        }
37
38 132
        $this->key = $key;
39
40 132
        return $this;
41
    }
42
43
    /**
44
     * Getter for the key string property.
45
     *
46
     * @return string The digestion key string.
47
     */
48 22
    public function getKey()
49
    {
50 22
        return $this->key;
51
    }
52
}
53