Completed
Pull Request — master (#26)
by Martin
12:26
created

BangMessage::bangText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 9.4285
1
<?php
2
declare(strict_types=1);
3
4
namespace Spires\Plugins\BangMessage\Inbound;
5
6
use Spires\Plugins\Message\Inbound\Message;
7
8
class BangMessage extends Message
9
{
10
    /**
11
     * The bang command
12
     * e.g. the message "!somersault mouse acrobat"
13
     * would return "somersault" as the bang command
14
     *
15
     * @return string
16
     */
17
    public function bangCommand()
18
    {
19
        list($bangCommand, $bangText) = explode(' ', $this->text(), 2);
0 ignored issues
show
Unused Code introduced by
The assignment to $bangText is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
20
21
        return ltrim($bangCommand, '!');
22
    }
23
24
    /**
25
     * The bang text
26
     * e.g. the message "!somersault mouse acrobat"
27
     * would return "mouse acrobat" as the bang text
28
     *
29
     * @return string
30
     */
31
    public function bangText()
32
    {
33
        list($bangCommand, $bangText) = explode(' ', $this->text(), 2);
0 ignored issues
show
Unused Code introduced by
The assignment to $bangCommand is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
34
35
        return $bangText;
36
    }
37
}
38