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

AsymmetricEncryptionInjectableTrait   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 getAsymmetricCipher() 0 3 1
A setAsymmetricCipher() 0 7 2
1
<?php
2
3
/**
4
 * Trait implementation of the setter dependency injection type for asymmetric algorithm services.
5
 */
6
7
namespace CryptoManana\Core\Traits\Containers;
8
9
use \CryptoManana\Core\Abstractions\MessageEncryption\AbstractAsymmetricEncryptionAlgorithm as AsymmetricEncryption;
10
use \CryptoManana\Core\Interfaces\Containers\AsymmetricEncryptionInjectableInterface as AsymmetricCipherSpecification;
11
use \CryptoManana\Core\Interfaces\MessageEncryption\DataEncryptionInterface as DataEncryption;
12
13
/**
14
 * Trait AsymmetricEncryptionInjectableTrait - Reusable implementation of `AsymmetricEncryptionInjectableInterface`.
15
 *
16
 * @see \CryptoManana\Core\Interfaces\Containers\AsymmetricEncryptionInjectableInterface The abstract specification.
17
 *
18
 * @package CryptoManana\Core\Traits\Containers
19
 *
20
 * @property AsymmetricEncryption|DataEncryption|null $asymmetricCipherSource The message asymmetric encryption service.
21
 *
22
 * @mixin AsymmetricCipherSpecification
23
 */
24
trait AsymmetricEncryptionInjectableTrait
25
{
26
    /**
27
     * Setter for the message asymmetric encryption service.
28
     *
29
     * @param AsymmetricEncryption|DataEncryption $cipher The message asymmetric encryption service.
30
     *
31
     * @return $this The container object.
32
     */
33
    public function setAsymmetricCipher(AsymmetricEncryption $cipher)
34
    {
35
        if ($cipher instanceof DataEncryption) {
36
            $this->asymmetricCipherSource = $cipher;
37
        }
38
39
        return $this;
40
    }
41
42
    /**
43
     * Getter for the message asymmetric encryption service.
44
     *
45
     * @return AsymmetricEncryption|DataEncryption|null The currently injected message encryption service or null.
46
     */
47
    public function getAsymmetricCipher()
48
    {
49
        return $this->asymmetricCipherSource;
50
    }
51
}
52