Widget   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A name() 0 4 1
A number() 0 4 1
A register() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the WPFoundation library.
5
 *
6
 * Copyright (c) 2015-present LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LIN3S\WPFoundation\Widgets;
13
14
/**
15
 * Abstract class of base Widget that implements the interface.
16
 *
17
 * @author Beñat Espiña <[email protected]>
18
 */
19
abstract class Widget extends \WP_Widget implements WidgetInterface
20
{
21
    /**
22
     * Constructor.
23
     *
24
     * @param string $id          The name id
25
     * @param string $name        The name
26
     * @param array  $description The description
27
     */
28
    public function __construct($id, $name, $description)
29
    {
30
        parent::__construct($id, $name, ['description' => $description]);
31
32
        add_action('widgets_init', [$this, 'register']);
0 ignored issues
show
Unused Code introduced by
The call to the function add_action() seems unnecessary as the function has no side-effects.
Loading history...
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function name()
39
    {
40
        return $this->id_base;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function number()
47
    {
48
        return $this->number;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function register()
55
    {
56
        register_widget(static::class);
0 ignored issues
show
Unused Code introduced by
The call to the function register_widget() seems unnecessary as the function has no side-effects.
Loading history...
57
    }
58
}
59