| 1 | <?php  | 
            ||
| 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()  | 
            ||
| 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()  | 
            ||
| 38 | |||
| 39 | /**  | 
            ||
| 40 | * Return the TemplateInterface being used by the matcher.  | 
            ||
| 41 | *  | 
            ||
| 42 | * @return TemplateInterface  | 
            ||
| 43 | */  | 
            ||
| 44 | public function getTemplate()  | 
            ||
| 52 | |||
| 53 | /**  | 
            ||
| 54 | * Set the TemplateInterface to use for formatting match results.  | 
            ||
| 55 | *  | 
            ||
| 56 | * @param TemplateInterface $template  | 
            ||
| 57 | * @return $this  | 
            ||
| 58 | */  | 
            ||
| 59 | public function setTemplate(TemplateInterface $template)  | 
            ||
| 65 | |||
| 66 | /**  | 
            ||
| 67 | * Set the Assertion bound to the matcher. Useful for checking  | 
            ||
| 68 | * flags from within a matcher.  | 
            ||
| 69 | *  | 
            ||
| 70 | * @param Assertion $assertion  | 
            ||
| 71 | * @return mixed  | 
            ||
| 72 | */  | 
            ||
| 73 | public function setAssertion(Assertion $assertion)  | 
            ||
| 79 | |||
| 80 | /**  | 
            ||
| 81 | * @var bool  | 
            ||
| 82 | */  | 
            ||
| 83 | protected $negated = false;  | 
            ||
| 84 | |||
| 85 | /**  | 
            ||
| 86 | * @var TemplateInterface  | 
            ||
| 87 | */  | 
            ||
| 88 | protected $template;  | 
            ||
| 89 | |||
| 90 | /**  | 
            ||
| 91 | * @var Assertion  | 
            ||
| 92 | */  | 
            ||
| 93 | protected $assertion;  | 
            ||
| 94 | }  | 
            ||
| 95 | 
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.