DebugDecorator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Mdanter\Ecc\Random;
5
6
class DebugDecorator implements RandomNumberGeneratorInterface
7
{
8
    /**
9
     * @var RandomNumberGeneratorInterface
10
     */
11
    private $generator;
12
13
    /**
14
     * @var string
15
     */
16
    private $generatorName;
17
18
    /**
19
     * @param RandomNumberGeneratorInterface $generator
20
     * @param string $name
21
     */
22
    public function __construct(RandomNumberGeneratorInterface $generator, string $name)
23
    {
24
        $this->generator = $generator;
25
        $this->generatorName = $name;
26
    }
27
28
    /**
29
     * @param \GMP $max
30
     * @return \GMP
31
     */
32
    public function generate(\GMP $max): \GMP
33
    {
34
        echo $this->generatorName.'::rand() = ';
35
36
        $result = $this->generator->generate($max);
37
38
        echo gmp_strval($result, 10).PHP_EOL;
39
40
        return $result;
41
    }
42
}
43