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

TruthyMatcher::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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