VisitorObserver   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 2
c 1
b 0
f 0
dl 0
loc 13
ccs 2
cts 2
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A creating() 0 3 1
1
<?php
2
3
/**
4
 * VisitorObserver.php
5
 *
6
 * Observers the creation of new Visitor objects to the database.
7
 * Upon creation it will add a unique identifier to the new Visitor.
8
 *
9
 * PHP version 7.2
10
 *
11
 * @category Observers
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\Observers;
20
21
use Redbox\Tracker\Visitor;
22
23
/**
24
 * Class VisitorObserver
25
 *
26
 * @category Observers
27
 * @package  RedboxTracker
28
 * @author   Johnny Mast <[email protected]>
29
 * @license  https://opensource.org/licenses/MIT MIT
30
 * @link     https://github.com/johnnymast/redbox-tracker
31
 * @since    GIT:1.0
32
 */
33
class VisitorObserver
34
{
35
    
36
    /**
37
     * Create a mew unique identifier for the new visitor.
38
     *
39
     * @param Visitor $visitor The visitor that is about to be created.
40
     *
41
     * @return void
42
     */
43 10
    public function creating($visitor): void
44
    {
45 10
        $visitor->unique_id = Visitor::createUniqueID();
46 10
    }
47
}
48