TrackController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A actionTrackEventUrl() 0 8 1
A actionTrackPageViewUrl() 0 4 1
1
<?php
2
/**
3
 * Instant Analytics plugin for Craft CMS
4
 *
5
 * Instant Analytics brings full Google Analytics support to your Twig templates
6
 *
7
 * @link      https://nystudio107.com
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @copyright tag
Loading history...
8
 * @copyright Copyright (c) 2017 nystudio107
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
9
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
10
11
namespace nystudio107\instantanalyticsGa4\controllers;
12
13
use craft\web\Controller;
14
use nystudio107\instantanalyticsGa4\InstantAnalytics;
15
16
/**
17
 * TrackController
18
 *
19
 * @author    nystudio107
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Coding Style introduced by
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
20
 * @package   InstantAnalytics
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
21
 * @since     1.0.0
0 ignored issues
show
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
Coding Style introduced by
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
22
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
23
class TrackController extends Controller
24
{
25
    // Protected Properties
26
    // =========================================================================
27
28
    protected array|bool|int $allowAnonymous = [
29
        'track-page-view-url',
30
        'track-event-url',
31
    ];
32
33
    // Public Methods
34
    // =========================================================================
35
36
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
37
     * @param string $url
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
38
     * @param string $title
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
39
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
40
    public function actionTrackPageViewUrl(string $url, string $title): void
41
    {
42
        InstantAnalytics::$plugin->ga4->addPageViewEvent($url, $title);
43
        $this->redirect($url, 200);
44
    }
45
46
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
47
     * @param string $url
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
48
     * @param string $eventName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
49
     * @param array $params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
50
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
51
    public function actionTrackEventUrl(
52
        string $url,
53
        string $eventName = '',
54
        array  $params = [],
55
    ): void {
56
        InstantAnalytics::$plugin->ga4->addSimpleEvent($url, $eventName, $params);
57
58
        $this->redirect($url, 200);
59
    }
60
}
61