Completed
Push — master ( ecb243...bb1b22 )
by Pablo
03:58
created

LocaleTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 42
loc 42
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A localeProvider() 10 10 1
A itShouldReturnLocale() 6 6 1
A invalidLocaleProvider() 7 7 1
A itShouldThrowsException() 6 6 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
declare(strict_types=1);
4
5
namespace PhpValueObjects\Tests\Geography;
6
7
use PhpValueObjects\Tests\BaseUnitTestCase;
8
9 View Code Duplication
final class LocaleTest extends BaseUnitTestCase
0 ignored issues
show
Duplication introduced by
This class 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...
10
{
11
    public function localeProvider(): array
12
    {
13
        return [
14
            ['es_ES'],
15
            ['es_AR'],
16
            ['en_GB'],
17
            ['en_US'],
18
19
        ];
20
    }
21
    /**
22
     * @test
23
     * @dataProvider localeProvider
24
     */
25
    public function itShouldReturnLocale(string $locale): void
26
    {
27
        $localeVO = new Locale($locale);
28
29
        $this->assertSame($locale, $localeVO->value());
30
    }
31
32
    public function invalidLocaleProvider(): array
33
    {
34
        return [
35
            [$this->faker()->address],
36
            [$this->faker()->numberBetween()],
37
        ];
38
    }
39
40
    /**
41
     * @test
42
     * @dataProvider invalidLocaleProvider
43
     */
44
    public function itShouldThrowsException(string $locale): void
45
    {
46
        $this->expectException(\Exception::class);
47
48
        new Locale($locale);
49
    }
50
}
51