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

GcmClientBuilder   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildPush() 0 18 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