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

ZendeskChannel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 31
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 10 2
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