Client   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 42
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A sendPayload() 0 6 1
A createApnMessage() 0 4 1
1
<?php
2
3
namespace JWage\APNS;
4
5
class Client
6
{
7
    /**
8
     * @var \JWage\APNS\SocketClient
9
     */
10
    private $socketClient;
11
12
    /**
13
     * Construct.
14
     *
15
     * @param \JWage\APNS\SocketClient $socketClient
16
     */
17
    public function __construct(SocketClient $socketClient)
18
    {
19
        $this->socketClient = $socketClient;
20
    }
21
22
    /**
23
     * Send Payload instance to a given device token.
24
     *
25
     * @param string $deviceToken The device token to send payload to.
26
     * @param \JWage\APNS\Payload $payload The payload to send to device token.
27
     */
28
    public function sendPayload($deviceToken, Payload $payload)
29
    {
30
        return $this->socketClient->write(
31
            $this->createApnMessage($deviceToken, $payload)->getBinaryMessage()
32
        );
33
    }
34
35
    /**
36
     * Creates an APNSMessage instance for the given device token and payload.
37
     *
38
     * @param string $deviceToken
39
     * @param \JWage\APNS\Payload $payload
40
     * @return \JWage\APNS\APNSMessage
41
     */
42
    protected function createApnMessage($deviceToken, Payload $payload)
43
    {
44
        return new APNSMessage($deviceToken, $payload);
45
    }
46
}
47