for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Http\ViewComposers;
use App\Repositories\CategoryRepository;
use Illuminate\Contracts\View\View;
class CategoryComposer extends Composer
{
/**
* @var CategoryRepository
*/
protected $categories;
* CategoryComposer constructor.
* @param CategoryRepository $categoryRepository
public function __construct(CategoryRepository $categoryRepository)
$this->categories = $categoryRepository;
}
* Bind data to view.
*
* @param View $view
* @return View
public function compose(View $view)
switch ($view->getName()){
case "partials.categories.l_sidebar":
return $view->with('categories', $this->categories->getSidebarCollection());
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 "partials.categories.footer":
return $view->with('categories', $this->categories->getFooterCollection());
case "partials.categories.header_dropdown":
return $view->with('categories', $this->categories->getSidebarCollection()); // the same select like l_sidebar
case "partials.categories.search_dropdown":
case "product.partials.form.index":
return $view->with('categories', $this->categories->getPublicCategories());
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.