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

SymmetricEncryptionInjectableTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 26
ccs 0
cts 10
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSymmetricCipher() 0 3 1
A setSymmetricCipher() 0 7 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