Completed
Pull Request — master (#22)
by Erin
02:35
created

EmptyMatcher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
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
 * EmptyMatcher determines if an actual value is empty via the php empty() function.
9
 * @package Peridot\Leo\Matcher
10
 */
11
class EmptyMatcher extends AbstractMatcher
12
{
13
    public function __construct()
14
    {
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