Completed
Push — master ( 01615d...a88e90 )
by Konstantinos
04:19
created

ConversationKickEvent::getKicked()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 4
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * This file contains a conversation event
4
 *
5
 * @license    https://github.com/allejo/bzion/blob/master/LICENSE.md GNU General Public License Version 3
6
 */
7
8
namespace BZIon\Event;
9
10
/**
11
 * Event announced when someone a player is kicked from a conversation
12
 */
13 View Code Duplication
class ConversationKickEvent extends Event
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    /**
16
     * @var \Conversation
17
     */
18
    protected $conversation;
19
20
    /**
21
     * @var \Player|\Team
22
     */
23
    protected $kicked;
24
25
    /**
26
     * @var \Player
27
     */
28
    protected $kicker;
29
30
    /**
31
     * Create a new event
32
     *
33
     * @param \Conversation        $conversation  The conversation from which the player was kicked
34
     * @param \Player|\Team $kicked The member who was kicked
35
     * @param \Player       $kicker The player who issued the kick
36
     */
37
    public function __construct(\Conversation $conversation, \Model $kicked, \Player $kicker)
38
    {
39
        $this->conversation = $conversation;
40
        $this->kicked = $kicked;
0 ignored issues
show
Documentation Bug introduced by
$kicked is of type object<Model>, but the property $kicked was declared to be of type object<Player>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
41
        $this->kicker = $kicker;
42
    }
43
44
    /**
45
     * Get the conversation from which the player was kicked
46
     *
47
     * @return \Conversation
48
     */
49
    public function getConversation()
50
    {
51
        return $this->conversation;
52
    }
53
54
    /**
55
     * Get the member who was kicked
56
     *
57
     * @return \Player|\Team
58
     */
59
    public function getKicked()
60
    {
61
        return $this->kicked;
62
    }
63
64
    /**
65
     * Get the member who was kicked
66
     *
67
     * Alias for ConversationKickEvent::getKicked()
68
     *
69
     * @return \Player|\Team
70
     */
71
    public function getMember()
72
    {
73
        return $this->kicked;
74
    }
75
76
77
    /**
78
     * Get the player who issued the kick
79
     *
80
     * @return \Player
81
     */
82
    public function getKicker()
83
    {
84
        return $this->kicker;
85
    }
86
}
87