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

MessageTextExtractor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B extractMessage() 0 22 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