Passed
Push — v1 ( 446664...610fc2 )
by Andrew
24:46 queued 14:33
created

InstantAnalyticsVariable::craft31()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Instant Analytics plugin for Craft CMS 3.x
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\instantanalytics\variables;
12
13
use nystudio107\instantanalytics\InstantAnalytics;
14
use nystudio107\instantanalytics\helpers\IAnalytics;
15
16
use craft\helpers\Template;
17
18
use \Twig\Markup;
19
20
/**
21
 * Instant Analytics Variable
22
 *
23
 * @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...
24
 * @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...
25
 * @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...
26
 */
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...
27
class InstantAnalyticsVariable extends ManifestVariable
28
{
29
    // Public Methods
30
    // =========================================================================
31
32
    /**
33
     * Get a PageView analytics object
34
     *
35
     * @param string $url
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
36
     * @param string $title
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
37
     *
38
     * @return null|IAnalytics object
39
     */
40
    public function pageViewAnalytics($url = '', $title = '')
41
    {
42
        return InstantAnalytics::$plugin->ia->pageViewAnalytics($url, $title);
43
    }
44
45
    /**
46
     * Get an Event analytics object
47
     *
48
     * @param string $eventCategory
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
49
     * @param string $eventAction
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
50
     * @param string $eventLabel
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
51
     * @param int    $eventValue
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
52
     *
53
     * @return null|IAnalytics
54
     */
55
    public function eventAnalytics($eventCategory = '', $eventAction = '', $eventLabel = '', $eventValue = 0)
56
    {
57
        return InstantAnalytics::$plugin->ia->eventAnalytics($eventCategory, $eventAction, $eventLabel, $eventValue);
58
    }
59
60
    /**
61
     * Return an Analytics object
62
     *
63
     * @return null|IAnalytics
64
     */
65
    public function analytics()
66
    {
67
        return InstantAnalytics::$plugin->ia->analytics();
68
    }
69
70
    /**
71
     * Get a PageView tracking URL
72
     *
73
     * @param $url
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
74
     * @param $title
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
75
     *
76
     * @return Markup
77
     * @throws \yii\base\Exception
78
     */
79
    public function pageViewTrackingUrl($url, $title): Markup
80
    {
81
        return Template::raw(InstantAnalytics::$plugin->ia->pageViewTrackingUrl($url, $title));
82
    }
83
84
    /**
85
     * Get an Event tracking URL
86
     *
87
     * @param        $url
0 ignored issues
show
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 1 spaces but found 8
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
88
     * @param string $eventCategory
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
89
     * @param string $eventAction
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
90
     * @param string $eventLabel
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
91
     * @param int    $eventValue
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
92
     *
93
     * @return Markup
94
     * @throws \yii\base\Exception
95
     */
96
    public function eventTrackingUrl(
97
        $url,
98
        $eventCategory = '',
99
        $eventAction = '',
100
        $eventLabel = '',
101
        $eventValue = 0
102
    ): Markup {
103
        return Template::raw(InstantAnalytics::$plugin->ia->eventTrackingUrl(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
104
            $url,
105
            $eventCategory,
106
            $eventAction,
107
            $eventLabel,
108
            $eventValue
109
        ));
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
110
    }
111
112
    /**
113
     * Return whether we are running Craft 3.1 or later
114
     *
115
     * @return bool
116
     */
117
    public function craft31(): bool
118
    {
119
        return InstantAnalytics::$craft31;
120
    }
121
}
122