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 |
||
| 20 | class Tag extends Model |
||
| 21 | { |
||
| 22 | use SoftDeletes; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * The attributes that are mass assignable. |
||
| 26 | * |
||
| 27 | * @var array |
||
| 28 | */ |
||
| 29 | protected $fillable = ['name', 'real_name', 'category_id']; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var array |
||
| 33 | */ |
||
| 34 | protected $dates = ['created_at', 'deleted_at']; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var string |
||
| 38 | */ |
||
| 39 | protected $dateFormat = 'Y-m-d H:i:se'; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @var bool |
||
| 43 | */ |
||
| 44 | public $timestamps = false; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
| 48 | */ |
||
| 49 | public function category() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @param string $value |
||
| 56 | * @return \Coyote\Services\Media\MediaInterface |
||
| 57 | */ |
||
| 58 | View Code Duplication | public function getLogoAttribute($value) |
|
| 67 | |||
| 68 | /** |
||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | public function __toString() |
||
| 75 | } |
||
| 76 |