Completed
Push — master ( ee19ca...fc64c3 )
by Rémi
03:30
created

MessageTextExtractor::extractMessage()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 8.6737
cc 5
eloc 10
nc 5
nop 2
crap 5
1
<?php
2
3
namespace MiniGameMessageApp\Message;
4
5
use MessageApp\Event\UnableToCreateUserEvent;
6
use MessageApp\Event\UserEvent;
7
use MessageApp\Parser\Exception\MessageParserException;
8
use MiniGame\GameResult;
9
10
class MessageTextExtractor
11
{
12
    /**
13
     * Extract the message from the game result.
14
     *
15
     * @param  object $object
16
     * @param  string $languageIso
17
     * @return string
18
     */
19 15
    public function extractMessage($object, $languageIso)
0 ignored issues
show
Unused Code introduced by
The parameter $languageIso is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
    {
21
        // TODO retrieve and translate the message / remove getAsMessage
22
23 15
        if ($object instanceof GameResult) {
24 3
            return $object->getAsMessage();
25
        }
26
27 12
        if ($object instanceof UnableToCreateUserEvent) {
28 3
            return $object->getReason();
29
        }
30
31 9
        if ($object instanceof UserEvent) {
32 3
            return $object->getAsMessage();
33
        }
34
35 6
        if ($object instanceof MessageParserException) {
36 3
            return $object->getMessage();
37
        }
38
39 3
        return null;
40
    }
41
}
42