for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Modules\Blog\Presenters;
use Laracasts\Presenter\Presenter;
use Modules\Blog\Entities\Status;
class PostPresenter extends Presenter
{
/**
* @var \Modules\Blog\Entities\Status
*/
protected $status;
* @var \Modules\Blog\Repositories\PostRepository
private $post;
public function __construct($entity)
parent::__construct($entity);
$this->post = app('Modules\Blog\Repositories\PostRepository');
$this->status = app('Modules\Blog\Entities\Status');
}
* Get the previous post of the current post
* @return object
public function previous()
return $this->post->getPreviousOf($this->entity);
* Get the next post of the current post
public function next()
return $this->post->getNextOf($this->entity);
* Get the post status
* @return string
public function status()
return $this->status->get($this->entity->status);
* Getting the label class for the appropriate status
public function statusLabelClass()
switch ($this->entity->status) {
case Status::DRAFT:
return 'bg-red';
break;
break
The break statement is not necessary if it is preceded for example by a return statement:
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 Status::PENDING:
return 'bg-orange';
case Status::PUBLISHED:
return 'bg-green';
case Status::UNPUBLISHED:
return 'bg-purple';
default:
The break statement is not necessary if it is preceded for example by a return 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.