Completed
Pull Request — master (#120)
by Gorka
02:41
created

Organization::removeParticipant()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Kreta\TaskManager\Domain\Model\Organization;
16
17
class Organization
18
{
19
    private $id;
20
21
    private $name;
22
23
    private $slug;
24
25
    private $owners;
26
27
    private $participants;
28
29
    public function __construct(OrganizationId $id, OrganizationName $name, OrganizationSlug $slug, Owner $creator)
30
    {
31
        $this->id = $id;
32
        $this->name = $name;
33
        $this->slug = $slug;
34
        $this->owners = new OwnerCollection();
35
        $this->participants = new ParticipantCollection();
36
        $this->addOwner($creator);
37
    }
38
39
    public function id() : OrganizationId
40
    {
41
        return $this->id;
42
    }
43
44
    public function __toString()
45
    {
46
        return (string) $this->id->id();
47
    }
48
49
    public function name() : OrganizationName
50
    {
51
        return $this->name;
52
    }
53
54
    public function slug() : OrganizationSlug
55
    {
56
        return $this->slug;
57
    }
58
59
    public function owners() : array
60
    {
61
        return $this->owners->toArray();
62
    }
63
64
    public function addOwner(Owner $owner)
65
    {
66
        $this->owners->add($owner);
67
    }
68
69
    public function removeOwner(Owner $owner)
70
    {
71
        $this->owners->remove($owner);
72
    }
73
74
    public function participants() : array
75
    {
76
        return $this->participants->toArray();
77
    }
78
79
    public function addParticipant(Participant $participant)
80
    {
81
        $this->participants->add($participant);
82
    }
83
84
    public function removeParticipant(Participant $participant)
85
    {
86
        $this->participants->remove($participant);
0 ignored issues
show
Documentation introduced by
$participant is of type object<Kreta\TaskManager...ganization\Participant>, but the function expects a string|integer.

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...
87
    }
88
}
89