Sender::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace JWage\APNS;
4
5
class Sender
6
{
7
    /**
8
     * @var \JWage\APNS\Client
9
     */
10
    private $client;
11
12
    /**
13
     * Construct.
14
     *
15
     * @param \JWage\APNS\Client $client
16
     */
17
    public function __construct(Client $client)
18
    {
19
        $this->client = $client;
20
    }
21
22
    /**
23
     * Sends a safari website push notification to the given deviceToken.
24
     *
25
     * @param string $deviceToken
26
     * @param string $title 
27
     * @param string $body
28
     * @param string $deepLink
29
     */
30
    public function send($deviceToken, $title, $body, $deepLink = null)
31
    {
32
        return $this->client->sendPayload(
33
            $deviceToken, $this->createPayload($title, $body, $deepLink)
34
        );
35
    }
36
37
    /**
38
     * Creates a Payload instance.
39
     *
40
     * @param string $title
41
     * @param string $body
42
     * @param string $deepLink
43
     * @return \JWage\APNS\Payload
44
     */
45
    private function createPayload($title, $body, $deepLink = null)
46
    {
47
        return new Payload($title, $body, $deepLink);
48
    }
49
}
50