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

Product::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 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