Refactor the isset condition in PHP, you can use the null coalescing operator in conjunction with the null-safe (also known as null propagation) operator to achieve the same result in a more concise way.
BAD
{{ (isset($rowData[$i]) ? $rowData[$i] : null) }}
GOOD
{{ $rowData[$i] ?? null }}
_Other Example _
BAD
if(isset($rowData['name'])){
$name = $rowData['name'];
}
elseif(isset($rowData['fullname'])){
$name = $rowData['fullname'];
}
else{
$name = 'nobody';
}
GOOD
$name = $rowData['name']) ?? $rowData['fullname']) ?? 'nobody'
Top comments (1)
Great!