Completed
Pull Request — master (#71)
by Sullivan
01:14
created

TestCase::getMock()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 10
dl 0
loc 4
rs 10
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace SLLH\ComposerVersionsCheck\Tests;
4
5
// PHPUnit >=6 Backward Compatibility
6
if (class_exists('\PHPUnit\Framework\TestCase')) {
7
    abstract class TestCase extends \PHPUnit\Framework\TestCase
8
    {
9
        public function getMock($originalClassName, $methods = [], $arguments = [], $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $cloneArguments = false, $callOriginalMethods = false, $proxyTarget = mull)
10
        {
11
            return $this->getMockBuilder($originalClassName)->getMock();
12
        }
13
    }
14
} else {
15
    abstract class TestCase extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type SLLH\ComposerVersionsCheck\Tests\TestCase has been defined more than once; this definition is ignored, only the first definition in this file (L7-13) 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...
16
    {
17
    }
18
}
19