Completed
Push — master ( 0318a4...4ae196 )
by Pol
02:45
created

Prime   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 22.22 %

Coupling/Cohesion

Dependencies 1

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generator() 0 3 1
A get() 6 8 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace drupol\phpermutations\Generators;
4
5
/**
6
 * Class Prime.
7
 *
8
 * @package drupol\phpermutations\Generators
9
 */
10
class Prime extends \drupol\phpermutations\Iterators\Prime {
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 View Code Duplication
    for ($j = 2; $j <= $this->getMaxLimit(); $j++) {
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...
29
      if ($this->isPrimeNumber($j)) {
30
        $this->count++;
31
        yield $j;
32
      }
33
    }
34
  }
35
36
}
37