Printer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 4
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 4
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0

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 Collision.
5
 *
6
 * (c) Nuno Maduro <[email protected]>
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 NunoMaduro\Collision\Adapters\Phpunit;
13
14
/*
15
 * This `if` condition exists because phpunit
16
 * is not a direct dependency of Collision.
17
 *
18
 * This code bellow it's for phpunit@8
19
 */
20 View Code Duplication
if (class_exists(\PHPUnit\Runner\Version::class) && intval(substr(\PHPUnit\Runner\Version::id(), 0, 1)) === 8) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
21
    /**
22
     * This is an Collision Phpunit Adapter implementation.
23
     *
24
     * @internal
25
     */
26
    final class Printer extends \PHPUnit\Util\Printer implements \PHPUnit\Framework\TestListener
0 ignored issues
show
Deprecated Code introduced by
The interface PHPUnit\Framework\TestListener has been deprecated with message: Use the `TestHook` interfaces instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
27
    {
28
        use PrinterContents;
29
    }
30
}
31
32
/*
33
 * This `if` condition exists because phpunit
34
 * is not a direct dependency of Collision.
35
 *
36
 * This code bellow it's for phpunit@9
37
 */
38 View Code Duplication
if (class_exists(\PHPUnit\Runner\Version::class) && intval(substr(\PHPUnit\Runner\Version::id(), 0, 1)) === 9) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
39
    /**
40
     * This is an Collision Phpunit Adapter implementation.
41
     *
42
     * @internal
43
     */
44
    final class Printer implements \PHPUnit\TextUI\ResultPrinter
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type NunoMaduro\Collision\Adapters\Phpunit\Printer has been defined more than once; this definition is ignored, only the first definition in this file (L26-29) is considered.

This check looks for classes that have been defined more than once in the same file.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
45
    {
46
        use PrinterContents;
47
48
        /**
49
         * Intentionally left blank as we output things on events of the listener.
50
         */
51
        public function printResult(\PHPUnit\Framework\TestResult $result): void
52
        {
53
            // ..
54
        }
55
    }
56
}
57