NewVisitorEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * NewVisitorEvent.php
5
 *
6
 * Laravel identification for the Tracker Facade defined in
7
 * TrackerServiceProvider.php.
8
 *
9
 * PHP version 7.2
10
 *
11
 * @category Events
12
 * @package  RedboxTracker
13
 * @author   Johnny Mast <[email protected]>
14
 * @license  https://opensource.org/licenses/MIT MIT
15
 * @link     https://github.com/johnnymast/redbox-tracker
16
 * @since    GIT:1.0
17
 */
18
19
namespace Redbox\Tracker\Events;
20
21
use Illuminate\Broadcasting\InteractsWithSockets;
22
use Illuminate\Foundation\Events\Dispatchable;
23
use Illuminate\Broadcasting\PrivateChannel;
24
use Redbox\Tracker\Visitor;
25
26
/**
27
 * Class NewVisitorEvent
28
 *
29
 * Identifies the Tracker Facade.
30
 *
31
 * PHP version 7.2
32
 *
33
 * @category Events
34
 * @package  RedboxTracker
35
 * @author   Johnny Mast <[email protected]>
36
 * @license  https://opensource.org/licenses/MIT MIT
37
 * @link     https://github.com/johnnymast/redbox-tracker
38
 * @since    GIT:1.0
39
 */
40
class NewVisitorEvent
41
{
42
    use Dispatchable;
43
    use InteractsWithSockets;
44
    
45
    /**
46
     * The new visitor is publicly available.
47
     *
48
     * @var Visitor $visitor the new visitor
49
     */
50
    public $visitor;
51
    
52
    /**
53
     * Create a new event instance.
54
     *
55
     * @param Visitor $visitor The newly created visitor.
56
     */
57 12
    public function __construct(Visitor $visitor)
58
    {
59 12
        $this->visitor = $visitor;
60 12
    }
61
    
62
    /**
63
     * Get the channels the event should broadcast on.
64
     *
65
     * @return PrivateChannel
66
     */
67
    public function broadcastOn(): PrivateChannel
68
    {
69
        return new PrivateChannel(config('redbox-tracker.events.channel'));
70
    }
71
}
72