Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 10 | View Code Duplication | class Role extends Model implements RoleHasRelationsContract |
|
| 11 | { |
||
| 12 | use Slugable, RoleHasRelations; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * The attributes that are mass assignable. |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $fillable = ['name', 'slug', 'description', 'level', 'parent_id']; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Create a new model instance. |
||
| 23 | * |
||
| 24 | * @param array $attributes |
||
| 25 | */ |
||
| 26 | public function __construct(array $attributes = []) |
||
| 34 | } |
||
| 35 |