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

Fibonacci   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
cbo 1
dl 0
loc 30
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generator() 0 3 1
A get() 0 11 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