Completed
Push — master ( d75d5a...4097cc )
by Abdullah
06:24
created

ZendeskChannel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace NotificationChannels\Zendesk;
4
5
use Zendesk\API\HttpClient;
6
use Illuminate\Notifications\Notification;
7
use NotificationChannels\Zendesk\Exceptions\CouldNotSendNotification;
8
9
class ZendeskChannel
10
{
11
    /** @var HttpClient */
12
    protected $client;
13
14
    /** @param HttpClient $client */
15 1
    public function __construct(HttpClient $client)
16
    {
17 1
        $this->client = $client;
18 1
    }
19
20
    /**
21
     * Send the given notification.
22
     *
23
     * @param mixed $notifiable
24
     * @param \Illuminate\Notifications\Notification $notification
25
     *
26
     * @throws \NotificationChannels\Zendesk\Exceptions\InvalidConfiguration
27
     * @throws \NotificationChannels\Zendesk\Exceptions\CouldNotSendNotification
28
     */
29 1
    public function send($notifiable, Notification $notification)
30
    {
31 1
        $zendeskParameters = $notification->toZendesk($notifiable)->toArray();
1 ignored issue
show
Bug introduced by
The method toZendesk() 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...
32
33
        try {
34 1
            $this->client->tickets()->create($zendeskParameters);
35
        } catch (\Exception $e) {
36
            throw CouldNotSendNotification::serviceRespondedWithAnError($e->getMessage());
37
        }
38 1
    }
39
}
40