| Total Complexity | 8 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 91.67% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class StubConfiguration |
||
| 8 | { |
||
| 9 | private $stubConfiguration; |
||
| 10 | |||
| 11 | private $testCase; |
||
| 12 | |||
| 13 | private $className; |
||
| 14 | |||
| 15 | 19 | public function __construct(TestCase $testCase) |
|
| 18 | 19 | } |
|
| 19 | |||
| 20 | 19 | public function setStubConfigurationArray(array $stubConfiguration): void |
|
| 21 | { |
||
| 22 | 19 | $this->stubConfiguration = $stubConfiguration; |
|
| 23 | 19 | $this->className = $this->getMockClassName($stubConfiguration); |
|
|
|
|||
| 24 | 19 | } |
|
| 25 | |||
| 26 | 19 | public function getStub() |
|
| 27 | { |
||
| 28 | 19 | if (empty($this->stubConfiguration)) { |
|
| 29 | 1 | throw new Parser\Exception\ParseException(); |
|
| 30 | } |
||
| 31 | |||
| 32 | 18 | $stub = $this->getInitialStub(); |
|
| 33 | |||
| 34 | 18 | foreach ($this->stubConfiguration[$this->className]['mockMethods'] as $methodName => $methodMockConfig) { |
|
| 35 | 18 | (new MockMethod\Resolver($this->testCase, $stub, $methodName, $methodMockConfig)) |
|
| 36 | 18 | ->resolveAndModifyStub(); |
|
| 37 | } |
||
| 38 | |||
| 39 | 18 | return $stub; |
|
| 40 | } |
||
| 41 | |||
| 42 | 18 | private function getInitialStub() |
|
| 52 | } |
||
| 53 | |||
| 54 | 19 | private function getMockClassName() |
|
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 60 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.