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 |
||
24 | public function run($n = 1000) |
||
|
|||
25 | { |
||
26 | $provider = Provider::withResource('generateDecimalFractions') |
||
27 | ->withParameters(['n' => $n * 2, 'decimalPlaces' => 6]); |
||
28 | |||
29 | $numbers = $this->getRandomOrgAPI()->getData($provider); |
||
30 | |||
31 | $inside = 0; |
||
32 | for ($i = 0; $i < $n; $i++) { |
||
33 | $x = $numbers[$i]; |
||
34 | $y = $numbers[$i+1]; |
||
35 | |||
36 | if (sqrt($x*$x + $y*$y) <= 1) { |
||
37 | $inside++; |
||
38 | } |
||
39 | } |
||
40 | |||
41 | $this->estimation = 4 * $inside/$n; |
||
42 | |||
43 | return $this; |
||
44 | } |
||
45 | |||
54 |
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.