DEV Community

Discussion on: Writing Clean Code

Collapse
 
juankoss profile image
Juan Koss

I think that example can be shorter too!
function canView($scope, $ownerId) {
return ($scope === 'public' ||
Auth::user()->hasRole('admin') ||
($scope === 'private' && Auth::user()->id === $ownerId));
}

Collapse
 
gonedark profile image
Jason McCreary

As noted in other comments, it's not about shorter, it's about more readable.