InstanceofMatcher   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 26
rs 10
c 1
b 0
f 1
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A doMatch() 0 4 1
A getDefaultTemplate() 0 7 1
1
<?php
2
3
namespace Peridot\Leo\Matcher;
4
5
use Peridot\Leo\Matcher\Template\ArrayTemplate;
6
use Peridot\Leo\Matcher\Template\TemplateInterface;
7
8
/**
9
 * InstanceofMatcher determines if the actual value is an instance of the expected
10
 * class string.
11
 *
12
 * @package Peridot\Leo\Matcher
13
 */
14
class InstanceofMatcher extends AbstractMatcher
15
{
16
    /**
17
     * See if actual value is an instance of the expected class.
18
     *
19
     * @param  mixed $actual
20
     * @return bool
21
     */
22
    protected function doMatch($actual)
23
    {
24
        return $actual instanceof $this->expected;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     *
30
     * @return TemplateInterface
31
     */
32
    public function getDefaultTemplate()
33
    {
34
        return new ArrayTemplate([
35
            'default' => 'Expected {{actual}} to be instance of {{expected}}',
36
            'negated' => 'Expected {{actual}} to not be an instance of {{expected}}',
37
        ]);
38
    }
39
}
40