| Total Complexity | 13 |
| Total Lines | 82 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class Articles extends Model |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var string |
||
| 12 | */ |
||
| 13 | protected $table = 'articles'; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | public $primaryKey = 'id'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var bool |
||
| 22 | */ |
||
| 23 | public $timestamps = true; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var array |
||
| 27 | */ |
||
| 28 | protected $dates = [ |
||
| 29 | 'created_at', |
||
| 30 | 'updated_at' |
||
| 31 | ]; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param $id |
||
| 35 | * @return array |
||
| 36 | */ |
||
| 37 | public function writer() { |
||
| 38 | $adminId = $this->getAttributeValue('admin_id'); |
||
| 39 | $doctorId = $this->getAttributeValue('doctor_id'); |
||
| 40 | |||
| 41 | $writer = ['role', 'data']; |
||
| 42 | |||
| 43 | if($adminId != null) { |
||
| 44 | $writer['role'] = "Admin"; |
||
| 45 | $writer['data'] = Admin::find($adminId); |
||
| 46 | } elseif($doctorId != null) { |
||
| 47 | $writer['role'] = "Dokter"; |
||
| 48 | $writer['data'] = Doctor::find($doctorId); |
||
| 49 | } |
||
| 50 | |||
| 51 | return $writer; |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @param $str |
||
| 56 | * @return string |
||
| 57 | */ |
||
| 58 | public function cutStr($str) |
||
| 59 | { |
||
| 60 | if (strlen($str) > 200){ |
||
| 61 | return substr($str,0,200) . "..."; |
||
| 62 | } |
||
| 63 | return $str; |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @param $str |
||
| 68 | * @return string |
||
| 69 | */ |
||
| 70 | public function trimStr($str) |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @param $str |
||
| 80 | * @return string |
||
| 81 | */ |
||
| 82 | public function getCat($str) |
||
| 90 | } |
||
| 91 | } |
||
| 92 | } |
||
| 93 |
The
breakstatement is not necessary if it is preceded for example by areturnstatement:If you would like to keep this construct to be consistent with other
casestatements, you can safely mark this issue as a false-positive.