CategoryComposer   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 47
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B compose() 0 24 6
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
}