InstanceofMatcher::getDefaultTemplate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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