PostsWidget::options()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
rs 9.4286
cc 1
eloc 5
nc 1
nop 0
1
<?php namespace Modules\Blog\Widgets;
2
3
use Modules\Blog\Repositories\PostRepository;
4
use Modules\Dashboard\Foundation\Widgets\BaseWidget;
5
6 View Code Duplication
class PostsWidget 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 \Modules\Blog\Repositories\PostRepository
10
     */
11
    private $post;
12
13
    public function __construct(PostRepository $post)
14
    {
15
        $this->post = $post;
16
    }
17
18
    /**
19
     * Get the widget name
20
     * @return string
21
     */
22
    protected function name()
23
    {
24
        return 'PostsWidget';
25
    }
26
27
    /**
28
     * Get the widget view
29
     * @return string
30
     */
31
    protected function view()
32
    {
33
        return 'blog::admin.widgets.posts';
34
    }
35
36
    /**
37
     * Get the widget data to send to the view
38
     * @return string
39
     */
40
    protected function data()
41
    {
42
        return ['postCount' => $this->post->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' => '0',
55
        ];
56
    }
57
}
58