IPAddressTests   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 24 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A randomNativeValue() 0 4 1
A invalidNativeValue() 0 4 1
A uniqueNativeValue() 0 4 1
A fromNative() 0 4 1
A testIsEmpty() 12 12 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
/**
4
 * This file is part of the Cubiche/Web component.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Domain\Web\Tests\Units;
13
14
use Cubiche\Domain\Web\IPAddress;
15
16
/**
17
 * IPAddressTests class.
18
 *
19
 * Generated by TestGenerator on 2017-03-15 at 11:36:08.
20
 */
21
class IPAddressTests extends HostTestCase
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function randomNativeValue()
27
    {
28
        return $this->faker->ipv6;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function invalidNativeValue()
35
    {
36
        return 'wrong@ip';
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    protected function uniqueNativeValue()
43
    {
44
        return $this->faker->unique()->ipv4;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    protected function fromNative($value)
51
    {
52
        return IPAddress::fromNative($value);
53
    }
54
55
    /**
56
     * Test isEmpty method.
57
     */
58 View Code Duplication
    public function testIsEmpty()
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...
59
    {
60
        $this
61
            ->given($email = IPAddress::fromNative($this->randomNativeValue()))
62
            ->then()
63
                ->boolean($email->isEmpty())
64
                    ->isFalse()
65
                ->exception(function () {
66
                    IPAddress::fromNative('');
67
                })->isInstanceOf(\InvalidArgumentException::class)
68
        ;
69
    }
70
}
71