Completed
Push — master ( b2313d...60d04d )
by Pol
02:05
created

Product   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 1

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generator() 0 3 1
B get() 0 14 5
1
<?php
2
3
namespace drupol\phpermutations\Generators;
4
5
/**
6
 * Class Product.
7
 *
8
 * @package drupol\phpermutations\Generators
9
 */
10
class Product extends \drupol\phpermutations\Iterators\Product {
11
12
  /**
13
   * @return \Generator
14
   */
15
  public function generator() {
16
    return $this->get($this->getDataset());
17
  }
18
19
  /**
20
   * @param $data
21
   *
22
   * @return \Generator
23
   */
24
  protected function get($data) {
25
    if ($data) {
26
      if ($u = array_pop($data)) {
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $u. 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...
27
        foreach ($this->get($data) as $p) {
28
          foreach ($u as $v) {
29
            yield $p + [count($p) => $v];
30
          }
31
        }
32
      }
33
    }
34
    else {
35
      yield [];
36
    }
37
  }
38
39
}
40