HostNameTests   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 25.53 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 2
dl 12
loc 47
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidNativeValue() 0 4 1
A fromNative() 0 4 1
A testIsEmpty() 12 12 1
A testIsValid() 0 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
/**
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\HostName;
15
16
/**
17
 * HostNameTests class.
18
 *
19
 * Generated by TestGenerator on 2017-03-15 at 11:36:08.
20
 */
21
class HostNameTests extends HostTestCase
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function invalidNativeValue()
27
    {
28
        return 'wrong@hostname';
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function fromNative($value)
35
    {
36
        return HostName::fromNative($value);
37
    }
38
39
    /**
40
     * Test isEmpty method.
41
     */
42 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...
43
    {
44
        $this
45
            ->given($email = HostName::fromNative($this->randomNativeValue()))
46
            ->then()
47
                ->boolean($email->isEmpty())
48
                    ->isFalse()
49
                ->exception(function () {
50
                    HostName::fromNative('');
51
                })->isInstanceOf(\InvalidArgumentException::class)
52
            ;
53
    }
54
55
    /**
56
     * Test IsValid method.
57
     */
58
    public function testIsValid()
59
    {
60
        $this
61
            ->boolean(HostName::isValid($this->randomNativeValue()))
62
                ->isTrue()
63
            ->boolean(HostName::isValid($this->invalidNativeValue()))
64
                ->isFalse()
65
        ;
66
    }
67
}
68