Completed
Push — master ( cef25e...758dfd )
by Hilmi Erdem
02:56
created

NumericNo0TokenGenerator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 18
ccs 0
cts 13
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPlainText() 0 4 1
A getRandomDigitWithNo0() 0 10 2
1
<?php
2
3
namespace Erdemkeren\TemporaryAccess\Token\TokenGenerator;
4
5
use Exception;
6
7
class NumericNo0TokenGenerator extends NumericTokenGenerator implements TokenGeneratorInterface
8
{
9
    protected function getPlainText($length)
10
    {
11
        return (string) str_replace(0, $this->getRandomDigitWithNo0(), (string) parent::getPlainText($length));
12
    }
13
14
    private function getRandomDigitWithNo0()
15
    {
16
        try {
17
            $int = random_int(1, 9);
18
        } catch (Exception $e) {
19
            $int = rand(1, 9);
20
        }
21
22
        return $int;
23
    }
24
}
25