Completed
Push — master ( 0b4795...d0bddc )
by Pol
02:26
created

PrimeFactors::get()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 14
Code Lines 8

Duplication

Lines 6
Ratio 42.86 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 14
ccs 0
cts 12
cp 0
rs 9.2
cc 4
eloc 8
nc 6
nop 0
crap 20
1
<?php
2
3
namespace drupol\phpermutations\Generators;
4
5
use drupol\phpermutations\Iterators\PrimeFactors as PrimeFactorsIterator;
6
7
/**
8
 * Class PrimeFactors.
9
 *
10
 * @package drupol\phpermutations\Generators
11
 */
12
class PrimeFactors extends PrimeFactorsIterator {
13
14
  /**
15
   * Alias of the get() method.
16
   *
17
   * @return \Generator
18
   *   The prime factors generator.
19
   */
20
  public function generator() {
21
    return $this->get();
22
  }
23
24
  /**
25
   * The generator.
26
   *
27
   * @codingStandardsIgnoreStart
28
   * @return \Generator
29
   *   The prime factors generator.
30
   * @codingStandardsIgnoreEnd
31
   */
32
  protected function get() {
33
    $number = $this->getNumber();
34
35 View Code Duplication
    for ($i = 2; $i <= $number / $i; $i++) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
      while ($number % $i == 0) {
37
        yield $i;
38
        $number /= $i;
39
      }
40
    }
41
42
    if ($number > 1) {
43
      yield $number;
44
    }
45
  }
46
47
}
48