Passed
Branch main (5bbbb9)
by Diego
04:08 queued 56s
created

News   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMutations() 0 4 1
1
<?php
2
3
namespace Blackmine\Model;
4
5
use Blackmine\Model\Project\Project;
6
use Blackmine\Model\User\User;
7
use Blackmine\Mutator\MutableInterface;
8
use Blackmine\Mutator\Mutation\RemoveKeyMutation;
9
use Carbon\CarbonImmutable;
10
11
/**
12
 * @method void setTitle(string $title)
13
 * @method void setSummary(string $summary)
14
 * @method void setDescription(string $description)
15
 * @method void setProject(Project $project)
16
 * @method void setAuthor(User $author)
17
 *
18
 * @method string getTitle()
19
 * @method string getSummary()
20
 * @method string getDescription()
21
 * @method Project getProject()
22
 * @method User getAuthor()
23
 * @method CarbonImmutable getCreatedOn()
24
 */
25
class News extends Identity implements FetchableInterface, MutableInterface
26
{
27
    public const ENTITY_NAME = "news";
28
29
    protected string $title;
30
    protected ?string $summary;
31
    protected string $description;
32
33
    protected Project $project;
34
    protected User $author;
35
36
    protected CarbonImmutable $created_on;
37
38
    public function getMutations(): array
39
    {
40
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array('created_on...ion::class => array())) returns the type array<string,array<string,array>> which is incompatible with the return type mandated by Blackmine\Mutator\MutableInterface::getMutations() of Blackmine\Mutator\Mutation\AbstractMutation[].

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...
41
            "created_on" => [RemoveKeyMutation::class => []]
42
        ];
43
    }
44
45
}
46