RandomnessInjectableTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setRandomGenerator() 0 5 1
A getRandomGenerator() 0 3 1
1
<?php
2
3
/**
4
 * Trait implementation of the setter dependency injection type for pseudo-random generator services.
5
 */
6
7
namespace CryptoManana\Core\Traits\Containers;
8
9
use CryptoManana\Core\Abstractions\Randomness\AbstractGenerator as RandomnessSource;
10
use CryptoManana\Core\Interfaces\Containers\RandomnessInjectableInterface as RandomnessInjectableSpecification;
11
12
/**
13
 * Trait RandomnessInjectableTrait - Reusable implementation of `RandomnessInjectableInterface`.
14
 *
15
 * @see \CryptoManana\Core\Interfaces\Containers\RandomnessInjectableInterface The abstract specification.
16
 *
17
 * @package CryptoManana\Core\Traits\Containers
18
 *
19
 * @property RandomnessSource|null $randomnessSource The randomness generator.
20
 *
21
 * @mixin RandomnessInjectableSpecification
22
 */
23
trait RandomnessInjectableTrait
24
{
25
    /**
26
     * Setter for the pseudo-random generator service.
27
     *
28
     * @param RandomnessSource $generator The pseudo-random generator service.
29
     *
30
     * @return $this The container object.
31
     */
32 27
    public function setRandomGenerator(RandomnessSource $generator)
33
    {
34 27
        $this->randomnessSource = $generator;
35
36 27
        return $this;
37
    }
38
39
    /**
40
     * Getter for the pseudo-random generator service.
41
     *
42
     * @return RandomnessSource|null The currently injected pseudo-random generator service.
43
     */
44 13
    public function getRandomGenerator()
45
    {
46 13
        return $this->randomnessSource;
47
    }
48
}
49