Passed
Push — master ( e9ba59...c2c890 )
by Tony Karavasilev (Тони
19:20
created

getSymmetricCipher()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * Trait implementation of the setter dependency injection type for symmetric algorithm services.
5
 */
6
7
namespace CryptoManana\Core\Traits\Containers;
8
9
use \CryptoManana\Core\Abstractions\MessageEncryption\AbstractBlockCipherAlgorithm as SymmetricBlockCipher;
10
use \CryptoManana\Core\Interfaces\Containers\SymmetricEncryptionInjectableInterface as SymmetricCipherSpecification;
11
use \CryptoManana\Core\Interfaces\MessageEncryption\DataEncryptionInterface as DataEncryption;
12
13
/**
14
 * Trait SymmetricEncryptionInjectableTrait - Reusable implementation of `SymmetricEncryptionInjectableInterface`.
15
 *
16
 * @see \CryptoManana\Core\Interfaces\Containers\SymmetricEncryptionInjectableInterface The abstract specification.
17
 *
18
 * @package CryptoManana\Core\Traits\Containers
19
 *
20
 * @property SymmetricBlockCipher|DataEncryption|null $symmetricCipherSource The message symmetric encryption service.
21
 *
22
 * @mixin SymmetricCipherSpecification
23
 */
24
trait SymmetricEncryptionInjectableTrait
25
{
26
    /**
27
     * Setter for the message symmetric encryption service.
28
     *
29
     * @param SymmetricBlockCipher|DataEncryption $cipher The message symmetric encryption service.
30
     *
31
     * @return $this The container object.
32
     */
33
    public function setSymmetricCipher(SymmetricBlockCipher $cipher)
34
    {
35
        if ($cipher instanceof DataEncryption) {
0 ignored issues
show
introduced by
$cipher is always a sub-type of CryptoManana\Core\Interf...DataEncryptionInterface.
Loading history...
36
            $this->symmetricCipherSource = $cipher;
37
        }
38
39
        return $this;
40
    }
41
42
    /**
43
     * Getter for the message symmetric encryption service.
44
     *
45
     * @return SymmetricBlockCipher|DataEncryption|null The currently injected message encryption service or null.
46
     */
47
    public function getSymmetricCipher()
48
    {
49
        return $this->symmetricCipherSource;
50
    }
51
}
52