Completed
Branch 2.x (d034bb)
by Julián
11:57
created

FcmReceiver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setToken() 0 12 2
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
 * FCM device receiver receiver.
17
 */
18
final class FcmReceiver implements Receiver
19
{
20
    use TokenTrait;
21
22
    /**
23
     * FCM device receiver 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