Completed
Push — master ( 1debd7...be65da )
by Jeroen
12:58 queued 12s
created

SitemapUrlTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 30 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 9
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testPriorityValues() 0 14 3
A priorityDataProvider() 9 9 1

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 Kunstmaan\SitemapBundle\Tests\unit\Model;
4
5
use Kunstmaan\SitemapBundle\Model\SitemapUrl;
6
use PHPUnit\Framework\TestCase;
7
8
class SitemapUrlTest extends TestCase
9
{
10
    /**
11
     * @dataProvider priorityDataProvider
12
     */
13
    public function testPriorityValues(float $priority, bool $expectException)
14
    {
15
        if ($expectException) {
16
            $this->expectException(\InvalidArgumentException::class);
17
            $this->expectExceptionMessage(sprintf('A sitemap url priority can\'t be higher than 1 or below 0. Value given "%s"', $priority));
18
        }
19
20
        $obj = new SitemapUrl('example-url', new \DateTimeImmutable(), $priority);
21
22
        if (!$expectException) {
23
            $this->assertInstanceOf(SitemapUrl::class, $obj);
24
            $this->assertSame($priority, $obj->getPriority());
25
        }
26
    }
27
28 View Code Duplication
    public function priorityDataProvider()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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
    {
30
        return [
31
            [0.0, false],
32
            [-1.0, true],
33
            [1.0, false],
34
            [1.2, true],
35
        ];
36
    }
37
}
38