Completed
Push — master ( 613542...020c5c )
by Julián
03:39
created

GcmClientBuilder::buildPush()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 1
eloc 10
nc 1
nop 1
1
<?php
2
/**
3
 * Push notification services abstraction (http://github.com/juliangut/tify)
4
 *
5
 * @link https://github.com/juliangut/tify for the canonical source repository
6
 *
7
 * @license https://github.com/juliangut/tify/blob/master/LICENSE
8
 */
9
10
namespace Jgut\Tify\Service\Client;
11
12
use Zend\Http\Client as HttpClient;
13
use Zend\Http\Client\Adapter\Socket;
14
use ZendService\Google\Gcm\Client;
15
16
/**
17
 * Class GcmClientBuilder
18
 */
19
class GcmClientBuilder
20
{
21
    /**
22
     * Get opened push service client.
23
     *
24
     * @param string $apiKey
25
     *
26
     * @return \ZendService\Google\Gcm\Client
27
     */
28
    public static function buildPush($apiKey)
29
    {
30
        $client = new Client;
31
        $client->setApiKey($apiKey);
32
33
        $httpClient = new HttpClient(
34
            null,
35
            [
36
                'service' => Socket::class,
37
                'strictredirects' => true,
38
                'sslverifypeer' => false,
39
            ]
40
        );
41
42
        $client->setHttpClient($httpClient);
43
44
        return $client;
45
    }
46
}
47