DerivationSaltingTrait::setDerivationSalt()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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