Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | public function run($throws = 1000) |
||
27 | { |
||
28 | $provider = Provider::withResource('generateDecimalFractions') |
||
29 | ->withParameters(['n' => $throws * 2, 'decimalPlaces' => 6]); |
||
30 | |||
31 | $numbers = $this->getRandomOrgAPI()->getData($provider); |
||
32 | |||
33 | $inside = 0; |
||
34 | for ($i = 0; $i < $throws; $i++) { |
||
35 | $x = $numbers[$i]; |
||
|
|||
36 | $y = $numbers[$i+1]; |
||
37 | |||
38 | if (sqrt($x*$x + $y*$y) <= 1) { |
||
39 | $inside++; |
||
40 | } |
||
41 | } |
||
42 | |||
43 | $this->estimation = 4 * $inside/$throws; |
||
44 | |||
45 | return $this; |
||
46 | } |
||
47 | |||
56 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.