Completed
Push — develop ( 90d434...5a25e9 )
by Michael
02:38
created

StringConverter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A convert() 0 10 2
1
<?php
2
3
namespace Crummy\Phlack\WebHook\Converter;
4
5
use Crummy\Phlack\WebHook\SlashCommand;
6
use Crummy\Phlack\WebHook\WebHook;
7
8
class StringConverter implements ConverterInterface
9
{
10
    protected $webHook = [
11
        'token'        => '',
12
        'team_id'      => '',
13
        'team_domain'  => '',
14
        'service_id'   => '',
15
        'channel_id'   => '',
16
        'channel_name' => '',
17
        'timestamp'    => 0.000000,
18
        'user_id'      => '',
19
        'user_name'    => '',
20
    ];
21
22
    protected $slashCommand = [
23
        'token'        => '',
24
        'team_id'      => '',
25
        'channel_id'   => '',
26
        'channel_name' => '',
27
        'user_id'      => '',
28
        'user_name'    => '',
29
    ];
30
31
    /**
32
     * @param $command
33
     *
34
     * @return \Crummy\Phlack\WebHook\CommandInterface
35
     */
36 2
    public function convert($command)
37
    {
38 2
        if (0 !== strpos($command, '/')) {
39 1
            return new WebHook(['text' => $command] + $this->webHook);
40
        } else {
41 1
            list($command, $text) = explode(' ', $command, 2);
42
43 1
            return new SlashCommand(['command' => $command, 'text' => $text] + $this->slashCommand);
44
        }
45
    }
46
}
47