for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Http\ViewComposers;
use App\Repositories\BannerRepository;
use Illuminate\Contracts\View\View;
class BannerComposer extends Composer
{
/**
* @var BannerRepository
*/
protected $banners;
* BannerComposer constructor.
* @param BannerRepository $bannerRepository
public function __construct(BannerRepository $bannerRepository)
$this->banners = $bannerRepository;
}
* @param View $view
* @return $this
public function compose(View $view)
// Here template names is hardcoded, but here is easy to edit them, then go to templates and change variables there
switch ($view->getName()){
case "partials.banners.small":
return $view->with('banners', $this->banners->getSmallAdBlocks(2));
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.banners.r_sidebar":
return $view->with('banners', $this->banners->getRightSideBarAdBlocks(1));
case "partials.banners.big":
return $view->with('banners', $this->banners->getBigAdBlocks(2));
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.