ObjectExpectations::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Dgame\Expectation;
4
5
/**
6
 * Class ObjectExpectations
7
 * @package Dgame\Expectation
8
 */
9
final class ObjectExpectations
10
{
11
    use ConditionTrait;
12
13
    /**
14
     * ObjectExpectations constructor.
15
     *
16
     * @param mixed $value
17
     */
18 2
    public function __construct($value)
19
    {
20 2
        if ($this->isObject($value)) {
21 2
            $this->value = $value;
22
        }
23 2
    }
24
25
    /**
26
     * @param mixed $value
27
     *
28
     * @return bool
29
     */
30 2
    private function isObject($value): bool
31
    {
32 2
        return $this->approveIf(is_object($value))->isApproved();
33
    }
34
35
    /**
36
     * @param mixed $object
37
     *
38
     * @return ObjectExpectations
39
     */
40 1
    public function isInstanceOf($object): self
41
    {
42 1
        return $this->approveIf($this->value instanceof $object);
43
    }
44
}
45