for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App;
use App\Doctor;
use Illuminate\Database\Eloquent\Model;
class Articles extends Model
{
/**
* @var string
*/
protected $table = 'articles';
public $primaryKey = 'id';
* @var bool
public $timestamps = true;
* @var array
protected $dates = [
'created_at',
'updated_at'
];
* @param $id
* @return array
public function writer() {
$adminId = $this->getAttributeValue('admin_id');
$doctorId = $this->getAttributeValue('doctor_id');
$writer = ['role', 'data'];
if($adminId != null) {
$writer['role'] = "Admin";
$writer['data'] = Admin::find($adminId);
} elseif($doctorId != null) {
$writer['role'] = "Dokter";
$writer['data'] = Doctor::find($doctorId);
}
return $writer;
* @param $str
* @return string
public function cutStr($str)
if (strlen($str) > 200){
return substr($str,0,200) . "...";
return $str;
public function getCat($str)
switch ($str) {
case "penyakit": return "Penyakit"; break;
break
The break statement is not necessary if it is preceded for example by a return statement:
return
switch ($x) { case 1: return 'foo'; break; // This break is not necessary and can be left off. }
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.
case
case "obat": return "Obat - obatan"; break;
case "hidup-sehat": return "Hidup Sehat"; break;
case "keluarga": return "Keluarga"; break;
case "kesehatan": return "Kesehatan"; break;
The
break
statement is not necessary if it is preceded for example by areturn
statement:If you would like to keep this construct to be consistent with other
case
statements, you can safely mark this issue as a false-positive.