InteractsWithContainer::partiallyMocks()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Cerbero\OctaneTestbench\Concerns;
4
5
use Mockery;
6
7
/**
8
 * The trait to interact with the IoC container.
9
 *
10
 */
11
trait InteractsWithContainer
12
{
13
    /**
14
     * Mock the given bound target
15
     *
16
     * @param string $target
17
     * @param mixed ...$parameters
18
     * @return static
19
     */
20 6
    public function mocks(string $target, ...$parameters): static
21
    {
22 6
        $mock = Mockery::mock($this->app[$target], ...$parameters);
23
24 6
        $this->app->instance($target, $mock);
25
26 6
        return $this;
27
    }
28
29
    /**
30
     * Partially mock the given bound target
31
     *
32
     * @param string $target
33
     * @param mixed ...$parameters
34
     * @return static
35
     */
36 1
    public function partiallyMocks(string $target, ...$parameters): static
37
    {
38 1
        $mock = Mockery::mock($this->app[$target], ...$parameters)->makePartial();
39
40 1
        $this->app->instance($target, $mock);
41
42 1
        return $this;
43
    }
44
}
45