Completed
Push — master ( f42091...b2313d )
by Pol
02:14
created

Product::generator()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 12
cts 12
cp 1
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 8
nc 5
nop 1
crap 5
1
<?php
2
3
namespace drupol\phpermutations\Generators;
4
5
/**
6
 * Class Product.
7
 *
8
 * @package drupol\phpermutations\Generators
9
 */
10
class Product {
11
12
  /**
13
   * @param $data
14
   *
15
   * @return \Generator
16
   */
17 2
  public function generator($data) {
18 2
    if ($data) {
19 2
      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...
20 2
        foreach ($this->generator($data) as $p) {
21 2
          foreach ($u as $v) {
22 2
            yield $p + [count($p) => $v];
23 2
          }
24 2
        }
25 2
      }
26 2
    }
27
    else {
28 2
      yield [];
29
    }
30 2
  }
31
32
}
33