GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 8e664d...8b2481 )
by Serge
02:00
created

Generator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types = 1);
3
namespace Converter\Demo;
4
5
use Converter\Init\Data;
6
7
class Generator
8
{
9
    public $exponent;
10
    public $sign;
11
    public $data;
12
13 9
    public function __construct()
14
    {
15 9
        $this->data = new Data();
16 9
    }
17
18
    /**
19
     * @param int|null $exponent - amount of gigits in resulting number
20
     * @param bool     $negative - set to true if you want negative number
21
     * @return string - generated number (can be safely passed to Number2Text class)
22
     */
23 7
    public function generate(int $exponent = null, bool $negative = false): string
24
    {
25 7
        $max = $this->data->getExpSize() * 3;
26 7
        $this->exponent = $exponent ?? mt_rand(1, $max);
27 7
        $this->sign = $negative ? '-' : '';
28 7
        $finalNumber = '';
29
30 7
        if ($this->exponent <= 0) {
31 3
            return "0";
32
        }
33
34 4
        for ($i = 1; $i <= $this->exponent; $i++) {
35 4
                $finalNumber .= mt_rand(1, 9);
36
        }
37
38 4
        return $this->sign . $finalNumber;
39
    }
40
}
41