Completed
Push — master ( dbd889...95c92d )
by Alberto
02:45
created

MockeryMockingStrategy::doGet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Moka\Strategy;
5
6
use Mockery\MockInterface;
7
use Moka\Stub\Stub;
8
use Moka\Stub\StubSet;
9
10
/**
11
 * Class MockeryMockingStrategy
12
 * @package Moka\Strategy
13
 */
14
class MockeryMockingStrategy extends AbstractMockingStrategy
15
{
16
    /**
17
     * MockeryMockingStrategy constructor.
18
     */
19 2
    public function __construct()
20
    {
21 2
        $this->setMockType(MockInterface::class);
22
    }
23
24
    /**
25
     * @param string $fqcn
26
     * @return MockInterface
27
     */
28 6
    protected function doBuild(string $fqcn)
29
    {
30 6
        return \Mockery::mock($fqcn);
31
    }
32
33
    /**
34
     * @param MockInterface $mock
35
     * @param StubSet $stubs
36
     * @return void
37
     */
38 1
    protected function doDecorate($mock, StubSet $stubs)
39
    {
40
        /** @var Stub $stub */
41 1
        foreach ($stubs as $stub) {
42 1
            $methodValue = $stub->getMethodValue();
43
44 1
            $partial = $mock->shouldReceive($stub->getMethodName())->zeroOrMoreTimes();
45 1
            $methodValue instanceof \Throwable
46 1
                ? $partial->andThrow($methodValue)
47 1
                : $partial->andReturn($methodValue);
48
        }
49
    }
50
51
    /**
52
     * @param MockInterface $mock
53
     * @return MockInterface
54
     */
55 3
    protected function doGet($mock)
56
    {
57 3
        return $mock;
58
    }
59
}
60