Song::setSrcId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PHPDish\DailySongPlugin\Entity;
4
5
use Carbon\Carbon;
6
use PHPDish\Bundle\CoreBundle\Model\DateTimeTrait;
7
use PHPDish\Bundle\CoreBundle\Model\EnabledTrait;
8
use PHPDish\Bundle\CoreBundle\Model\IdentifiableTrait;
9
use PHPDish\DailySongPlugin\Model\SongInterface;
10
11
class Song implements SongInterface
12
{
13
    use IdentifiableTrait;
14
    use DateTimeTrait;
15
    use EnabledTrait;
16
17
    /**
18
     * @var string
19
     */
20
    protected $name;
21
22
    /**
23
     * @var string
24
     */
25
    protected $srcId;
26
27
    /**
28
     * @var string
29
     */
30
    protected $src;
31
32
    public function __construct()
33
    {
34
        $this->createdAt = $this->updatedAt = Carbon::now();
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getName()
41
    {
42
        return $this->name;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function setName($name)
49
    {
50
        $this->name = $name;
51
52
        return $this;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function getSrcId()
59
    {
60
        return $this->srcId;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->srcId returns the type string which is incompatible with the return type mandated by PHPDish\DailySongPlugin\...ngInterface::getSrcId() of integer|double.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function setSrcId($srcId)
67
    {
68
        $this->srcId = $srcId;
69
70
        return $this;
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function getSrc()
77
    {
78
        return $this->src;
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function setSrc($src)
85
    {
86
        $this->src = $src;
87
88
        return $this;
89
    }
90
}