Slack   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A send() 0 10 2
1
<?php
2
3
namespace EricMakesStuff\ServerMonitor\Notifications\Senders;
4
5
use Illuminate\Contracts\Config\Repository;
6
use Maknz\Slack\Client;
7
use EricMakesStuff\ServerMonitor\Notifications\BaseSender;
8
9
class Slack extends BaseSender
10
{
11
    /** @var \Maknz\Slack\Client */
12
    protected $client;
13
14
    /** @var array */
15
    protected $config;
16
17
    /**
18
     * @param \Maknz\Slack\Client $client
19
     * @param Repository          $config
20
     */
21
    public function __construct(Client $client, Repository $config)
22
    {
23
        $this->config = $config->get('server-monitor.notifications.slack');
0 ignored issues
show
Documentation Bug introduced by
It seems like $config->get('server-mon...r.notifications.slack') of type * is incompatible with the declared type array of property $config.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
24
25
        $client->setDefaultUsername($this->config['username']);
26
        $client->setDefaultIcon($this->config['icon']);
27
28
        $this->client = $client;
29
    }
30
31
    public function send()
32
    {
33
        $this->client
34
            ->to($this->config['channel'])
35
            ->attach([
36
                'text' => $this->message,
37
                'color' => $this->type === static::TYPE_SUCCESS ? 'good' : 'warning',
38
            ])
39
            ->send($this->subject);
40
    }
41
}
42