Completed
Push — master ( e05d39...8cf173 )
by Gareth
02:39
created

NotificationAPI::subscribeToPushNotifications()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 5
dl 0
loc 20
ccs 0
cts 18
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace garethp\ews;
4
5
use garethp\ews\API\ClassMap;
6
use garethp\ews\API\Type\BaseFolderIdType;
7
use garethp\ews\API\Type\FolderIdType;
8
9
class NotificationAPI extends API
10
{
11
    public function subscribeToPushNotifications(
12
        BaseFolderIdType $folderId,
13
        array $events,
14
        $url,
15
        $frequency,
16
        array $options = array()
17
    ) {
18
        $request = [
19
            'EventTypes' => ['EventType' => $events],
20
            'URL' => $url,
21
            'StatusFrequency' => $frequency,
22
            'FolderIds' =>  $folderId->toArray(true)
23
        ];
24
25
        $request = array_replace_recursive($request, $options);
26
27
        return $this->getClient()->Subscribe([
28
            'PushSubscriptionRequest' => $request
29
        ]);
30
    }
31
32
    public static function handlePullNotification($uri, callable $handle, array $options = array())
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
    {
34
        $server = new \SoapServer(
35
            __DIR__ . '/../Resources/wsdl/notification-service.wsdl',
36
            [
37
                'uri' => $uri,
38
                'classmap' => ClassMap::getClassMap(),
39
            ]
40
        );
41
        $server->setObject(new NotificationHandler($handle));
42
        $server->handle();
43
44
        return $server;
45
    }
46
}
47