NotificationApi   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A post() 0 11 3
1
<?php
2
/**
3
 * This file is part of the fnayou/instapush-php project.
4
 *
5
 * Copyright (c) 2017. Aymen FNAYOU <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Fnayou\InstapushPHP\Api;
12
13
use Fnayou\InstapushPHP\Exception\ApiException;
14
use Fnayou\InstapushPHP\Model\Notification;
15
16
/**
17
 * Class NotificationApi.
18
 */
19
class NotificationApi extends AbstractApi
20
{
21
    /**
22
     * @param \Fnayou\InstapushPHP\Model\Notification $notification
23
     *
24
     * @throws \Fnayou\InstapushPHP\Exception\ApiException
25
     *
26
     * @return bool
27
     */
28
    public function post(Notification $notification)
29
    {
30
        $notificationApi = $this->doPost('/post', $notification->toArray());
31
32
        if (200 !== $notificationApi->getResponse()->getStatusCode()
33
            && 201 !== $notificationApi->getResponse()->getStatusCode()) {
34
            throw new ApiException('cannot send notification', $this->getRequest(), $this->getResponse());
35
        }
36
37
        return true;
38
    }
39
}
40