| Conditions | 1 |
| Paths | 1 |
| Total Lines | 24 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | protected function beforeUpdate() |
||
| 49 | { |
||
| 50 | $this->addValidator('name') |
||
| 51 | ->required() |
||
| 52 | ->latin() |
||
| 53 | ->callback( |
||
| 54 | function ($name) { |
||
| 55 | return !in_array(strtolower($name), Table::getInstance()->getBasicRoles(), false); |
||
| 56 | }, |
||
| 57 | 'Role is basic and can\'t be editable' |
||
| 58 | ) |
||
| 59 | ->callback( |
||
| 60 | function ($name) { |
||
| 61 | return $this->clean['name'] != $name; |
||
| 62 | }, |
||
| 63 | 'Role name is the same as original' |
||
| 64 | ) |
||
| 65 | ->callback( |
||
| 66 | function ($name) { |
||
| 67 | return !Table::findRowWhere(['name' => $name]); |
||
| 68 | }, |
||
| 69 | 'Role already exists' |
||
| 70 | ); |
||
| 71 | } |
||
| 72 | |||
| 83 |
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.