Completed
Push — master ( db951a...900abb )
by Michael
03:40
created

Command::logDebug()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace SugaredRim\PHPUnit\TextUI;
4
5
use Psr\Log\LoggerInterface;
6
use Schnittstabil\ComposerExtra\ComposerExtra;
7
use Schnittstabil\Get\Get;
8
9
if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
10 View Code Duplication
    class Command extends BaseCommand
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...
11
    {
12
        /**
13
         * {@inheritdoc}
14
         *
15
         * @SuppressWarnings(PHPMD.StaticAccess)
16
         */
17
        public function handleArguments(array $argv): void
18
        {
19
            parent::handleArguments($argv);
20
21
            if (Get::value('sugaredDebug', $this->arguments, false)) {
22
                $this->logDebug('Parsed arguments', $this->arguments);
23
            }
24
25
            $this->addListeners();
26
        }
27
28
        /**
29
         * {@inheritdoc}
30
         *
31
         * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
32
         */
33
        public function run(array $argv, $exit = true): int
34
        {
35
            $argv = $this->preprocessArgv($argv);
36
37
            if (in_array('--sugared-debug', $argv)) {
38
                $this->logDebug('Arguments', $argv);
39
            }
40
41
            return parent::run($argv, $exit);
42
        }
43
    }
44
} else {
45 View Code Duplication
    class Command extends BaseCommand
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type SugaredRim\PHPUnit\TextUI\Command has been defined more than once; this definition is ignored, only the first definition in this file (L10-43) 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...
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...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
46
    {
47
        /**
48
         * {@inheritdoc}
49
         *
50
         * @SuppressWarnings(PHPMD.StaticAccess)
51
         */
52
        public function handleArguments(array $argv)
53
        {
54
            parent::handleArguments($argv);
55
56
            if (Get::value('sugaredDebug', $this->arguments, false)) {
57
                $this->logDebug('Parsed arguments', $this->arguments);
58
            }
59
60
            $this->addListeners();
61
        }
62
63
        /**
64
         * {@inheritdoc}
65
         *
66
         * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
67
         */
68
        public function run(array $argv, $exit = true)
69
        {
70
            $argv = $this->preprocessArgv($argv);
71
72
            if (in_array('--sugared-debug', $argv)) {
73
                $this->logDebug('Arguments', $argv);
74
            }
75
76
            return parent::run($argv, $exit);
77
        }
78
    }
79
}
80