Issues (587)

src/controllers/TrackController.php (30 issues)

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
The tag in position 1 should be the @copyright tag
Loading history...
8
 * @copyright Copyright (c) 2017 nystudio107
0 ignored issues
show
@copyright tag must contain a year and the name of the copyright holder
Loading history...
9
 */
0 ignored issues
show
PHP version not specified
Loading history...
Missing @category tag in file comment
Loading history...
Missing @package tag in file comment
Loading history...
Missing @author tag in file comment
Loading history...
Missing @license tag in file comment
Loading history...
10
11
namespace nystudio107\instantanalytics\controllers;
12
13
use craft\web\Controller;
14
use nystudio107\instantanalytics\InstantAnalytics;
15
16
/**
17
 * TrackController
18
 *
19
 * @author    nystudio107
0 ignored issues
show
The tag in position 1 should be the @package tag
Loading history...
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
20
 * @package   InstantAnalytics
0 ignored issues
show
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
21
 * @since     1.0.0
0 ignored issues
show
The tag in position 3 should be the @author tag
Loading history...
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
22
 */
0 ignored issues
show
Missing @category tag in class comment
Loading history...
Missing @license tag in class comment
Loading history...
Missing @link tag in class comment
Loading history...
23
class TrackController extends Controller
24
{
25
26
    // Protected Properties
27
    // =========================================================================
28
29
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
30
     * @var    bool|array Allows anonymous access to this controller's actions.
31
     *         The actions must be in 'kebab-case'
32
     * @access protected
33
     */
34
    protected $allowAnonymous = [
35
        'track-page-view-url',
36
        'track-event-url'
37
    ];
38
39
    // Public Methods
40
    // =========================================================================
41
42
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
43
     * @param string $url
0 ignored issues
show
Missing parameter comment
Loading history...
44
     * @param string $title
0 ignored issues
show
Missing parameter comment
Loading history...
45
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
46
    public function actionTrackPageViewUrl(string $url, string $title)
47
    {
48
        $analytics = InstantAnalytics::$plugin->ia->pageViewAnalytics($url, $title);
49
        if ($analytics !== null) {
50
            $analytics->sendPageview();
51
        }
52
        $this->redirect($url, 200);
53
    }
54
55
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
56
     * @param string $url
0 ignored issues
show
Missing parameter comment
Loading history...
57
     * @param string $eventCategory
0 ignored issues
show
Missing parameter comment
Loading history...
58
     * @param string $eventAction
0 ignored issues
show
Missing parameter comment
Loading history...
59
     * @param string $eventLabel
0 ignored issues
show
Missing parameter comment
Loading history...
60
     * @param int $eventValue
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 4 spaces after parameter type; 1 found
Loading history...
61
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
62
    public function actionTrackEventUrl(
63
        string $url,
64
        string $eventCategory,
65
        string $eventAction,
66
        string $eventLabel,
67
        int    $eventValue
68
    )
69
    {
0 ignored issues
show
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Loading history...
70
        $analytics = InstantAnalytics::$plugin->ia->eventAnalytics(
71
            $eventCategory,
72
            $eventAction,
73
            $eventLabel,
74
            $eventValue
75
        );
76
        // Get the file name
77
        $path = parse_url($url, PHP_URL_PATH);
78
        if ($analytics !== null) {
79
            $analytics->setDocumentPath($path)
80
                ->sendEvent();
81
        }
82
        $this->redirect($url, 200);
83
    }
84
}
85