Completed
Push — master ( 4ae196...831fe8 )
by Pol
02:12
created

Fibonacci::generator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace drupol\phpermutations\Generators;
4
5
/**
6
 * Class Fibonacci.
7
 *
8
 * @package drupol\phpermutations\Generators
9
 */
10
class Fibonacci extends \drupol\phpermutations\Iterators\Fibonacci {
11
12
  /**
13
   * @var int
14
   */
15
  protected $max;
16
17
  /**
18
   * @return \Generator
19
   */
20
  public function generator() {
21
    return $this->get();
22
  }
23
24
  /**
25
   * @return \Generator
26
   */
27
  protected function get() {
28
    $a = 0;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $a. Configured minimum length is 3.

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.

Loading history...
29
    $b = 1;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $b. Configured minimum length is 3.

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.

Loading history...
30
    $to = $this->getMaxLimit();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $to. Configured minimum length is 3.

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.

Loading history...
31
    while ($to > 0) {
32
      yield $a;
33
34
      list($a, $b) = array($b, $a + $b);
35
      $to--;
36
    }
37
  }
38
39
}
40