Passed
Push — master ( d5b831...554623 )
by Greg
02:16
created

Pushbullet::pushNote()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
namespace GJClasses;
3
4
class Pushbullet
5
{
6
    public function push($api_key, $type, $subject, $content, $url)
7
    {
8
        if ($type == 'note') {
9
10
            $message = $this->pushNote($api_key, $subject, $content);
11
12
        } elseif ($type == 'url') {
13
14
            $message = $this->pushUrl($api_key, $subject, $content, $url);
15
16
        } else {
17
18
            $message = 'Push type incorrect or not specified';
19
20
        }
21
22
        return $message;
23
    }
24
25
    public function pushNote($api_key, $subject, $content)
26
    {
27
        $push = new \Pushbullet\Pushbullet($api_key);
28
        $push->allDevices()->pushNote($subject, $content);
29
        return 'Note Sent';
30
    }
31
32
    public function pushUrl($api_key, $subject, $content, $url)
33
    {
34
        $push = new \Pushbullet\Pushbullet($api_key);
35
        $push->allDevices()->pushLink($subject, $url, $content);
36
        return 'URL Sent';
37
    }
38
}
39