EmptyMatcher::doMatch()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 1
b 0
f 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
 * EmptyMatcher determines if an actual value is empty via the php empty() function.
10
 * @package Peridot\Leo\Matcher
11
 */
12
class EmptyMatcher extends AbstractMatcher
13
{
14
    public function __construct()
15
    {
16
    }
17
18
    /**
19
     * Determin if the actual value is empty.
20
     *
21
     * @param $actual
22
     * @return mixed
23
     */
24
    protected function doMatch($actual)
25
    {
26
        return empty($actual);
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     *
32
     * @return TemplateInterface
33
     */
34
    public function getDefaultTemplate()
35
    {
36
        return new ArrayTemplate([
37
            'default' => 'Expected {{actual}} to be empty',
38
            'negated' => 'Expected {{actual}} not to be empty',
39
        ]);
40
    }
41
}
42