CategoryComposer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace App\Http\ViewComposers;
4
5
use App\Repositories\CategoryRepository;
6
use Illuminate\Contracts\View\View;
7
8
class CategoryComposer extends Composer
9
{
10
    /**
11
     * @var CategoryRepository
12
     */
13
    protected $categories;
14
15
    /**
16
     * CategoryComposer constructor.
17
     * @param CategoryRepository $categoryRepository
18
     */
19
    public function __construct(CategoryRepository $categoryRepository)
20
    {
21
        $this->categories = $categoryRepository;
22
    }
23
24
    /**
25
     * Bind data to view.
26
     * 
27
     * @param View $view
28
     * @return View
29
     */
30
    public function compose(View $view)
31
    {
32
        switch ($view->getName()){
33
            case "partials.categories.l_sidebar":
34
                return $view->with('categories', $this->categories->getSidebarCollection());
35
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

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.

Loading history...
36
37
            case "partials.categories.footer":
38
                return $view->with('categories', $this->categories->getFooterCollection());
39
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

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.

Loading history...
40
41
            case "partials.categories.header_dropdown":
42
                return $view->with('categories', $this->categories->getSidebarCollection()); // the same select like l_sidebar
43
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

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.

Loading history...
44
45
            case "partials.categories.search_dropdown":
46
                return $view->with('categories', $this->categories->getSidebarCollection()); // the same select like l_sidebar
47
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

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.

Loading history...
48
49
            case "product.partials.form.index":
50
                return $view->with('categories', $this->categories->getPublicCategories());
51
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

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.

Loading history...
52
        }
53
    }
54
}