VisitorObserver::creating()   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 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
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
 * 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