Total Complexity | 6 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 69.23% |
Changes | 0 |
1 | <?php |
||
8 | class IdRegistry implements IdHandlerInterface |
||
9 | { |
||
10 | private $ids = []; |
||
11 | /** |
||
12 | * @var \Faker\Generator |
||
13 | */ |
||
14 | private $faker; |
||
15 | |||
16 | 9 | public function __construct() |
|
17 | { |
||
18 | 9 | $this->faker = Factory::create(); |
|
19 | 9 | } |
|
20 | |||
21 | public function generateStringId(string $entity): string |
||
26 | } |
||
27 | |||
28 | 3 | public function generateIntId(string $entity, bool $increment): int |
|
29 | { |
||
30 | 3 | if ($increment) { |
|
31 | 3 | $this->ids[$entity] = isset($this->ids[$entity]) ? ++$this->ids[$entity] : 1; |
|
32 | } else { |
||
33 | $this->ids[$entity] = $this->faker->unique()->numberBetween(0,100); |
||
34 | } |
||
35 | |||
36 | 3 | return $this->ids[$entity]; |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param string $entity |
||
41 | * @return mixed |
||
42 | */ |
||
43 | 3 | public function getId(string $entity) |
|
46 | } |
||
47 | } |
||
48 |