Total Complexity | 8 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
5 | class IntGuesser extends AbstractGuesser implements GuesserInterface |
||
6 | { |
||
7 | public function supports(array $mapping) |
||
8 | { |
||
9 | $mapping = array_merge([ 'type' => null ], $mapping); |
||
10 | |||
11 | return $mapping['type'] === 'integer'; |
||
12 | } |
||
13 | |||
14 | public function transform($str, array $mapping = null) |
||
15 | { |
||
16 | return (int) round($str); |
||
17 | } |
||
18 | |||
19 | public function fake(array $mapping) |
||
20 | { |
||
21 | $min = 0; |
||
22 | $max = $this->determineMaxValue($mapping); |
||
23 | |||
24 | return current($this->fakers)->fake('numberBetween', [$min, $max]); |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @param array $mapping |
||
29 | * |
||
30 | * @return int |
||
31 | */ |
||
32 | private function determineMaxValue(array $mapping) |
||
50 | } |
||
51 | |||
52 | public function getName() |
||
55 | } |
||
56 | } |
||
57 |