1.2.1366. Used Once Trait¶
Trait should promote code reuse and be used multiple time. A trait that is used once might be as well merged into its host class, and removed. This is currently overengineered code.
<?php
trait t {
function foo() {}
}
class x {
// This expression may be replaced by the foo method definition
use t;
}
?>
Name |
Default |
Type |
Description |
timeUsed |
2 |
integer |
Maximal number of trait usage, before the trait is considered enough used. |
1.2.1366.1. Suggestions¶
Inline the trait with its calling class or trait
Use the trait in another class or trait
1.2.1366.2. Specs¶
Short name |
Traits/UsedOnceTrait |
Rulesets |
|
Exakat since |
2.4.2 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Features |
code-reuse, overenginereed |
Available in |