Completed
Push — master ( e1eaf9...3b6dfb )
by Thanos
01:48
created

ValueReturn::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace Amock\MockMethod;
4
5 View Code Duplication
class ValueReturn extends Handler
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...
6
{
7
    public function handle(): bool
8
    {
9
        if (!$this->canHandle()) {
10
            return false;
11
        }
12
13
        $this->initialStub
14
            ->method($this->methodName)
15
            ->willReturn($this->returnValue());
16
17
        return true;
18
    }
19
20
    private function canHandle(): bool
21
    {
22
        return is_string($this->methodMockConfig)
23
            && substr($this->methodMockConfig, 0, 7) === '@value:';
24
    }
25
26
    private function returnValue(): string
27
    {
28
        return substr($this->methodMockConfig, 7);
29
    }
30
}
31