Completed
Pull Request — master (#23)
by Erin
03:28
created

InstanceofMatcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

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