| 1 | <?php |
||
| 11 | trait InflectionTableizeTrait |
||
| 12 | { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Converts a class name to its table name according to rails |
||
| 16 | * naming conventions. |
||
| 17 | * |
||
| 18 | * Converts "Person" to "people" |
||
| 19 | * |
||
| 20 | * @param string $class_name Class name for getting related table_name. |
||
| 21 | * @return string plural_table_name |
||
| 22 | */ |
||
| 23 | protected function doTableize($class_name) |
||
| 27 | } |
||
| 28 |
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.