CategoriesWidget   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 0
dl 52
loc 52
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A name() 4 4 1
A view() 4 4 1
A data() 4 4 1
A options() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace Modules\Blog\Widgets;
2
3
use Modules\Blog\Repositories\CategoryRepository;
4
use Modules\Dashboard\Foundation\Widgets\BaseWidget;
5
6 View Code Duplication
class CategoriesWidget extends BaseWidget
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
7
{
8
    /**
9
     * @var CategoryRepository
10
     */
11
    private $category;
12
13
    public function __construct(CategoryRepository $category)
14
    {
15
        $this->category = $category;
16
    }
17
18
    /**
19
     * Get the widget name
20
     * @return string
21
     */
22
    protected function name()
23
    {
24
        return 'CategoriesWidget';
25
    }
26
27
    /**
28
     * Get the widget view
29
     * @return string
30
     */
31
    protected function view()
32
    {
33
        return 'blog::admin.widgets.categories';
34
    }
35
36
    /**
37
     * Get the widget data to send to the view
38
     * @return string
39
     */
40
    protected function data()
41
    {
42
        return ['categoryCount' => $this->category->all()->count()];
43
    }
44
45
    /**
46
     * Get the widget type
47
     * @return string
48
     */
49
    protected function options()
50
    {
51
        return [
52
            'width' => '2',
53
            'height' => '2',
54
            'x' => '2',
55
        ];
56
    }
57
}
58