Completed
Push — master ( dfbcf7...f0faac )
by Pablo
03:11
created

Md5ValueObjectTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 39
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A itShouldReturnMd5Hash() 9 9 1
A invalidMd5HashProvider() 8 8 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
namespace PhpValueObjects\Tests\Identity;
4
5
use PhpValueObjects\Identity\Exception\InvalidMd5Exception;
6
use PhpValueObjects\Tests\BaseUnitTestCase;
7
8 View Code Duplication
class Md5ValueObjectTest 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...
9
{
10
    /**
11
     * @test
12
     */
13
    public function itShouldReturnMd5Hash()
14
    {
15
        $md5Hash = $this->faker()->Md5;
0 ignored issues
show
Bug introduced by
The property Md5 does not seem to exist in Faker\Generator.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
16
17
        $md5VO = new Md5ValueObject($md5Hash);
18
19
        $this->assertSame($md5Hash, $md5VO->value());
20
        $this->assertSame($md5Hash, $md5VO->__toString());
21
    }
22
23
    /**
24
     * @return array
25
     */
26
    public function invalidMd5HashProvider()
27
    {
28
        return [
29
            [$this->faker()->sha1],
30
            [$this->faker()->sha256],
31
            [$this->faker()->text],
32
        ];
33
    }
34
35
    /**
36
     * @test
37
     *
38
     * @dataProvider invalidMd5HashProvider
39
     */
40
    public function itShouldThrowsException($data)
41
    {
42
        $this->expectException(InvalidMd5Exception::class);
43
44
        new Md5ValueObject($data);
45
    }
46
}
47