Slack::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
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