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

NotificationAPI   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 38
ccs 0
cts 31
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A subscribeToPushNotifications() 0 20 1
A handlePullNotification() 0 14 1
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