ConsecutiveCallsReturn   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 29
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A canHandle() 0 3 1
A handle() 0 11 2
A transformValue() 0 9 4
1
<?php
2
3
namespace Amock\MockMethod;
4
5
class ConsecutiveCallsReturn extends Handler
6
{
7 11
    public function handle(): bool
8
    {
9 11
        if (!$this->canHandle()) {
10 2
            return false;
11
        }
12
13 10
        $this->initialStub->method($this->methodName)->will(
14 10
            call_user_func_array([$this->testCase, 'onConsecutiveCalls'], $this->transformValue())
15
        );
16
17 10
        return true;
18
    }
19
20 11
    private function canHandle(): bool
21
    {
22 11
        return is_array($this->methodMockConfig);
23
    }
24
25
    private function transformValue()
26
    {
27 10
        array_walk($this->methodMockConfig, function(&$value, &$key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

27
        array_walk($this->methodMockConfig, function(&$value, /** @scrutinizer ignore-unused */ &$key) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28 10
            $value = (substr($value, 0, 8) === '@string:') ? substr($value, 8) : $value;
29 10
            $value = (substr($value, 0, 9) === '@integer:') ? intval(substr($value, 9)) : $value;
30 10
            $value = (substr($value, 0, 9) === '@boolean:') ? filter_var(substr($value, 9), FILTER_VALIDATE_BOOLEAN) : $value;
31 10
        });
32
33
        return $this->methodMockConfig;
34
    }
35
}
36