Completed
Push — master ( aae44d...5e2102 )
by WEBEWEB
07:32
created

AbstractNotification   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 64
c 0
b 0
f 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getContent() 0 3 1
A getType() 0 3 1
A setContent() 0 4 1
A setType() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
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 WBW\Bundle\CoreBundle\Notification;
13
14
/**
15
 * Abstract notification.
16
 *
17
 * @author webeweb <https://github.com/webeweb/>
18
 * @package WBW\Bundle\CoreBundle\Notification
19
 * @abstract
20
 */
21
abstract class AbstractNotification implements NotificationInterface {
22
23
    /**
24
     * Content.
25
     *
26
     * @var string
27
     */
28
    private $content;
29
30
    /**
31
     * Type.
32
     *
33
     * @var string
34
     */
35
    private $type;
36
37
    /**
38
     * Constructor.
39
     *
40
     * @param string $type The type.
41
     * @param string $content The content.
42
     */
43
    protected function __construct($type, $content) {
44
        $this->setContent($content);
0 ignored issues
show
Documentation introduced by
$content is of type string, but the function expects a object<WBW\Bundle\CoreBundle\Notification\type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
45
        $this->setType($type);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function getContent() {
52
        return $this->content;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function getType() {
59
        return $this->type;
60
    }
61
62
    /**
63
     * Set the content.
64
     *
65
     * @param type $content The content.
66
     * @return NotificcationInterface Returns this notification.
67
     */
68
    protected function setContent($content) {
69
        $this->content = $content;
0 ignored issues
show
Documentation Bug introduced by
It seems like $content of type object<WBW\Bundle\CoreBundle\Notification\type> is incompatible with the declared type string of property $content.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
70
        return $this;
71
    }
72
73
    /**
74
     * Set the type.
75
     *
76
     * @param string $type The type.
77
     * @return NotificationInterface Returns this notification.
78
     */
79
    protected function setType($type) {
80
        $this->type = $type;
81
        return $this;
82
    }
83
84
}
85