| 1 | <?php |
||
| 20 | trait CriteriaTrait |
||
| 21 | { |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var CriteriaInterface |
||
| 25 | */ |
||
| 26 | private $criteria; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Returns the criteria. |
||
| 30 | * @return CriteriaInterface the query criteria |
||
| 31 | * @since v1.0 |
||
| 32 | */ |
||
| 33 | 1 | public function getCriteria() |
|
| 43 | |||
| 44 | /** |
||
| 45 | * Sets the query criteria. |
||
| 46 | * @param CriteriaInterface|array $criteria the query criteria. Array representing the MongoDB query criteria. |
||
| 47 | * @return static |
||
| 48 | */ |
||
| 49 | public function setCriteria($criteria) |
||
| 66 | |||
| 67 | } |
||
| 68 |
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.