| 1 | <?php |
||
| 16 | trait Executable |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var PDO |
||
| 20 | */ |
||
| 21 | protected $pdo; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var int |
||
| 25 | */ |
||
| 26 | protected $rowCount; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Sets the PDO instance used by this query. |
||
| 30 | * |
||
| 31 | * @param PDO $pdo |
||
| 32 | * |
||
| 33 | * @return self |
||
| 34 | */ |
||
| 35 | public function setPDO(PDO $pdo) |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Gets the PDO instance used by this query. |
||
| 44 | * |
||
| 45 | * @return PDO |
||
| 46 | */ |
||
| 47 | public function getPDO() |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Executes a query. |
||
| 54 | * |
||
| 55 | * @return \PDOStatement|bool result |
||
| 56 | */ |
||
| 57 | public function execute() |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Returns the number of rows affected by the last executed statement. |
||
| 72 | * |
||
| 73 | * @return int |
||
| 74 | */ |
||
| 75 | public function rowCount() |
||
| 79 | } |
||
| 80 |
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.