IftttWebhookChannel::setParams()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Arimolzer\IftttWebhook\Channels;
4
5
use Arimolzer\IftttWebhook\Exceptions\IftttWebhookException;
6
use Illuminate\Notifications\Notification;
7
8
/**
9
 * Class IftttWebhookChannel
10
 * @package Arimolzer\IftttWebhook\Channels
11
 */
12
class IftttWebhookChannel
13
{
14
    /** @var string $key */
15
    protected $key;
16
17
    /** @var string $event */
18
    protected $event;
19
20
    /** @var string $param1 */
21
    protected $param1;
22
23
    /** @var string $param2 */
24
    protected $param2;
25
26
    /** @var string $param3 */
27
    protected $param3;
28
29
    /**
30
     * @param $notifiable
31
     * @param Notification $notification
32
     * @return bool
33
     * @throws \Arimolzer\IftttWebhook\Exceptions\IftttWebhookException
34
     */
35
    public function send($notifiable, Notification $notification) : bool
36
    {
37
        // Return immediately if IFTTT Voip is disabled in config
38
        if (!config('ifttt-webhook.enabled')) {
39
            return false;
40
        }
41
42
        /** @var IftttWebhookChannel $message */
43
        $message = $notification->toIftttWebhook($notifiable);
0 ignored issues
show
Bug introduced by
The method toIftttWebhook() does not seem to exist on object<Illuminate\Notifications\Notification>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
45
        try {
46
            return IftttWebhook::call($message->param1, $message->param2, $message->param3, $message->event, $message->key);
47
        } catch (\Exception $e) {
48
            throw new IftttWebhookException();
49
        }
50
    }
51
52
    /**
53
     * @param string $key
54
     * @param string $event
55
     * @return IftttWebhookChannel $this
56
     */
57
    public function setConfig(string $key, string $event) : IftttWebhookChannel
58
    {
59
        $this->key = $key;
60
        $this->event = $event;
61
        return $this;
62
    }
63
64
    /**
65
     * @param null $param1
66
     * @param null $param2
67
     * @param null $param3
68
     * @return $this
69
     */
70
    public function setParams($param1 = null, $param2 = null, $param3 = null) : IftttWebhookChannel
71
    {
72
        // Set the params - Currently limited to 3 by IFTTT.
73
        $this->param1 = $param1;
74
        $this->param2 = $param2;
75
        $this->param3 = $param3;
76
        return $this;
77
    }
78
}
79