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

ZendeskChannel::send()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.1481

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 4
cts 6
cp 0.6667
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 2
crap 2.1481
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