Completed
Push — feature/sass-standard ( 554da1...a5bd48 )
by Vladimir
12:37 queued 09:02
created

ConversationQueryBuilder::forPlayer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 11
loc 11
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * This file contains a class to quickly generate database queries for conversations
4
 *
5
 * @package    BZiON\Models\QueryBuilder
6
 * @license    https://github.com/allejo/bzion/blob/master/LICENSE.md GNU General Public License Version 3
7
 */
8
9
/**
10
 * This class can be used to search for conversations  with specific
11
 * characteristics in the database.
12
 *
13
 * @package    BZiON\Models\QueryBuilder
14
 */
15
class ConversationQueryBuilder extends QueryBuilder
16
{
17
    /**
18
     * Only return messages that are sent from/to a specific player
19
     *
20
     * @param  Player $player The player related to the messages
21
     * @return self
22
     */
23 1 View Code Duplication
    public function forPlayer($player)
0 ignored issues
show
Duplication introduced by
This method 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...
24
    {
25 1
        $this->extras .= '
26
            LEFT JOIN player_conversations ON player_conversations.conversation=conversations.id
27
        ';
28
29 1
        $this->column('player_conversations.player')->is($player);
30 1
        $this->column('conversations.status')->isOneOf(Conversation::getActiveStatuses());
31
32 1
        return $this;
33
    }
34
35
    /**
36
     * Only return messages that are sent from/to a specific team
37
     *
38
     * @param  Team $team The team related to the messages
39
     * @return self
40
     */
41
    public function forTeam($team)
42
    {
43
        $this->extras .= '
44
            LEFT JOIN team_conversations ON team_conversations.conversation=conversations.id
45
        ';
46
47
        $this->column('team_conversations.team')->is($team);
48
        $this->column('conversations.status')->notEquals('deleted');
49
50
        return $this;
51
    }
52
}
53