Pushover::send()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 1
nop 0
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
1
<?php
2
3
namespace EricMakesStuff\ServerMonitor\Notifications\Senders;
4
5
use Illuminate\Contracts\Config\Repository;
6
use EricMakesStuff\ServerMonitor\Notifications\BaseSender;
7
8
class Pushover extends BaseSender
9
{
10
    /** @var array */
11
    protected $config;
12
13
    /**
14
     * @param Repository $config
15
     */
16
    public function __construct(Repository $config)
17
    {
18
        $this->config = $config->get('server-monitor.notifications.pushover');
0 ignored issues
show
Documentation Bug introduced by
It seems like $config->get('server-mon...otifications.pushover') 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...
19
    }
20
21
    public function send()
22
    {
23
        curl_setopt_array($ch = curl_init(), [
24
            CURLOPT_URL => 'https://api.pushover.net/1/messages.json',
25
            CURLOPT_POSTFIELDS => [
26
                'token' => $this->config['token'],
27
                'user' => $this->config['user'],
28
                'title' => $this->subject,
29
                'message' => $this->message,
30
                'sound' => $this->type === static::TYPE_SUCCESS ? 'pushover' : 'siren',
31
            ],
32
            CURLOPT_SAFE_UPLOAD => true,
33
            CURLOPT_RETURNTRANSFER => true,
34
        ]);
35
        curl_exec($ch);
36
        curl_close($ch);
37
    }
38
}
39