Completed
Pull Request — master (#95)
by
unknown
09:09 queued 06:40
created

Pushover   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 16 2
1
<?php
2
3
namespace Spatie\Backup\Notifications\Senders;
4
5
use Illuminate\Contracts\Config\Repository;
6
use Spatie\Backup\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('laravel-backup.notifications.pushover');
0 ignored issues
show
Documentation Bug introduced by
It seems like $config->get('laravel-ba...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
        ]);
34
        curl_exec($ch);
35
        curl_close($ch);
36
    }
37
}
38