RandomnessInjectableTrait::getRandomGenerator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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