ObjectExpectations   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A isObject() 0 4 1
A isInstanceOf() 0 4 1
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