Completed
Push — master ( a3ba2f...57d762 )
by Erin
02:00
created

MatcherTrait::setAssertion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace Peridot\Leo\Matcher;
4
5
use Peridot\Leo\Assertion;
6
use Peridot\Leo\Matcher\Template\TemplateInterface;
7
8
/**
9
 * MatcherTrait provides some common implementation details for matchers.
10
 *
11
 * @package Peridot\Leo\Matcher
12
 */
13
trait MatcherTrait
14
{
15
    /**
16
     * Returns whether or not the matcher is negated. A negated matcher negates
17
     * the results of a match.
18
     *
19
     * @return bool
20
     */
21
    public function isNegated()
22
    {
23
        return $this->negated;
24
    }
25
26
    /**
27
     * Inverts a matcher. If a matcher is not negated, it will become negated. If a matcher
28
     * is negated, it will no longer be negated.
29
     *
30
     * @return $this
31
     */
32
    public function invert()
33
    {
34
        $this->negated = !$this->negated;
35
36
        return $this;
37
    }
38
39
    /**
40
     * Set the TemplateInterface to use for formatting match results.
41
     *
42
     * @param  TemplateInterface $template
43
     * @return $this
44
     */
45
    public function setTemplate(TemplateInterface $template)
46
    {
47
        $this->template = $template;
48
49
        return $this;
50
    }
51
52
    /**
53
     * Set the Assertion bound to the matcher. Useful for checking
54
     * flags from within a matcher.
55
     *
56
     * @param  Assertion $assertion
57
     * @return mixed
58
     */
59
    public function setAssertion(Assertion $assertion)
60
    {
61
        $this->assertion = $assertion;
62
63
        return $this;
64
    }
65
66
    /**
67
     * @var bool
68
     */
69
    protected $negated = false;
70
71
    /**
72
     * @var TemplateInterface
73
     */
74
    protected $template;
75
76
    /**
77
     * @var Assertion
78
     */
79
    protected $assertion;
80
}
81