Completed
Branch 2.x (59be6b)
by Julián
11:20
created

GcmReceiver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * Unified push notification services abstraction (http://github.com/juliangut/tify).
5
 *
6
 * @license BSD-3-Clause
7
 * @link https://github.com/juliangut/tify
8
 * @author Julián Gutiérrez <[email protected]>
9
 */
10
11
namespace Jgut\Tify\Receiver;
12
13
use Jgut\Tify\Receiver\Traits\TokenTrait;
14
15
/**
16
 * GCM device receiver.
17
 */
18
final class GcmReceiver implements Receiver
19
{
20
    use TokenTrait;
21
22
    /**
23
     * Constructor.
24
     *
25
     * @param string $token
26
     *
27
     * @throws \InvalidArgumentException
28
     */
29
    public function __construct($token)
30
    {
31
        $this->setToken($token);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     *
37
     * @throws \InvalidArgumentException
38
     */
39
    public function setToken($token)
40
    {
41
        $token = trim($token);
42
43
        if ($token === '') {
44
            throw new \InvalidArgumentException('GCM token can not be empty');
45
        }
46
47
        $this->token = $token;
48
49
        return $this;
50
    }
51
}
52