DeviceObserver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 31
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A deleted() 0 6 1
1
<?php
2
3
namespace PiFinder\Observers;
4
5
use Vinkla\Pusher\PusherManager;
6
use PiFinder\Transformers\DeviceTransformer;
7
8
class DeviceObserver
9
{
10
    /**
11
     * @var PusherManager
12
     */
13
    protected $pusher;
14
15
    /**
16
     * @var DeviceTransformer
17
     */
18
    private $transformer;
19
20
    /**
21
     * DeviceObserver constructor.
22
     *
23
     * @param PusherManager     $pusher
24
     * @param DeviceTransformer $transformer
25
     */
26 10
    public function __construct(PusherManager $pusher, DeviceTransformer $transformer)
27
    {
28 10
        $this->pusher = $pusher;
29 10
        $this->transformer = $transformer;
30 10
    }
31
32 2
    public function deleted($device)
33
    {
34 2
        $this->pusher->trigger(config('broadcasting.connections.pusher.channel'), 'DeviceWasDeleted', [
35 2
            'device' => $this->transformer->transform($device),
36
        ]);
37 2
    }
38
}
39