We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
5 | trait HasIdentifiableAttribute |
||
6 | { |
||
7 | /** |
||
8 | * Get the name of the attribute that best defines the entry, from the user perspective. |
||
9 | * |
||
10 | * Rephrased: In most cases a user will NOT identify an Article because its ID is "4", but |
||
11 | * because its name is "10 Ways to Burn Fat". This method returns the column in the database |
||
12 | * that represents that is better to show to the user as an identifier rather than the ID. |
||
13 | * Ex: name, title, label, description etc. |
||
14 | * |
||
15 | * @return string The name of the column that best defines this entry from the user perspective. |
||
16 | */ |
||
17 | public static function getIdentifiableName() |
||
26 | |||
27 | /** |
||
28 | * Get the most likely column in the db table that could be used as an identifiable attribute. |
||
29 | * |
||
30 | * @return string The name of the column in the database that is most likely to be a good indentifying attribute. |
||
31 | */ |
||
32 | public static function guessIdentifiableColumnName() |
||
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
Idable
provides a methodequalsId
that 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.