setAsymmetricCipher()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 1
crap 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 4
    public function setAsymmetricCipher(AsymmetricEncryption $cipher)
34
    {
35 4
        if ($cipher instanceof DataEncryption) {
36 4
            $this->asymmetricCipherSource = $cipher;
37
        }
38
39 4
        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 6
    public function getAsymmetricCipher()
48
    {
49 6
        return $this->asymmetricCipherSource;
50
    }
51
}
52