Handler   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 7
c 3
b 1
f 0
lcom 1
cbo 0
dl 0
loc 52
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A push() 0 8 3
A getSupportedPlatforms() 0 12 3
1
<?php
2
3
namespace WZRD\Push;
4
5
use WZRD\Contracts\Push\Notification as NotificationContract;
6
use WZRD\Contracts\Push\Pusher;
7
8
class Handler implements Pusher
9
{
10
    /**
11
     * Pushers.
12
     *
13
     * @var WZRD\Contracts\Push\Pusher[]
14
     */
15
    protected $pushers;
16
17
    /**
18
     * Construct with pushers instances.
19
     *
20
     * @param WZRD\Contracts\Push\Pusher[] $pushers
21
     */
22
    public function __construct(array $pushers)
23
    {
24
        $this->pushers = $pushers;
25
    }
26
27
    /**
28
     * Push message.
29
     *
30
     * @param WZRD\Contracts\Push\Notification $notification
31
     * @param array                            $options
32
     */
33
    public function push(NotificationContract $notification, array $options = [])
34
    {
35
        foreach ($this->pushers as $pusher) {
36
            if ($pusher instanceof Pusher) {
37
                $pusher->push($notification, $options);
38
            }
39
        }
40
    }
41
42
    /**
43
     * Get supported platforms.
44
     *
45
     * @return array
46
     */
47
    public function getSupportedPlatforms()
48
    {
49
        $platforms = [];
50
51
        foreach ($this->pushers as $pusher) {
52
            if ($pusher instanceof Pusher) {
53
                $platforms = array_merge($platforms, $pusher->getSupportedPlatforms());
54
            }
55
        }
56
57
        return array_unique($platforms);
58
    }
59
}
60