InstantAnalyticsVariable::craft31()   A
last analyzed

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
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 craft\helpers\Template;
14
use nystudio107\instantanalytics\helpers\IAnalytics;
15
use nystudio107\instantanalytics\InstantAnalytics;
16
use nystudio107\pluginvite\variables\ViteVariableInterface;
17
use nystudio107\pluginvite\variables\ViteVariableTrait;
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 implements ViteVariableInterface
28
{
29
    use ViteVariableTrait;
30
31
    // Public Methods
32
    // =========================================================================
33
34
    /**
35
     * Get a PageView analytics object
36
     *
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
     *
40
     * @return null|IAnalytics object
41
     */
42
    public function pageViewAnalytics($url = '', $title = '')
43
    {
44
        return InstantAnalytics::$plugin->ia->pageViewAnalytics($url, $title);
45
    }
46
47
    /**
48
     * Get an Event analytics object
49
     *
50
     * @param string $eventCategory
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
51
     * @param string $eventAction
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
52
     * @param string $eventLabel
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
53
     * @param int $eventValue
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 1 found
Loading history...
54
     *
55
     * @return null|IAnalytics
56
     */
57
    public function eventAnalytics($eventCategory = '', $eventAction = '', $eventLabel = '', $eventValue = 0)
58
    {
59
        return InstantAnalytics::$plugin->ia->eventAnalytics($eventCategory, $eventAction, $eventLabel, $eventValue);
60
    }
61
62
    /**
63
     * Return an Analytics object
64
     *
65
     * @return null|IAnalytics
66
     */
67
    public function analytics()
68
    {
69
        return InstantAnalytics::$plugin->ia->analytics();
70
    }
71
72
    /**
73
     * Get a PageView tracking URL
74
     *
75
     * @param $url
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
76
     * @param $title
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
77
     *
78
     * @return Markup
79
     * @throws \yii\base\Exception
80
     */
81
    public function pageViewTrackingUrl($url, $title): Markup
82
    {
83
        return Template::raw(InstantAnalytics::$plugin->ia->pageViewTrackingUrl($url, $title));
84
    }
85
86
    /**
87
     * Get an Event tracking URL
88
     *
89
     * @param        $url
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 1 spaces but found 8
Loading history...
90
     * @param string $eventCategory
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
91
     * @param string $eventAction
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
92
     * @param string $eventLabel
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
93
     * @param int $eventValue
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 1 found
Loading history...
94
     *
95
     * @return Markup
96
     * @throws \yii\base\Exception
97
     */
98
    public function eventTrackingUrl(
99
        $url,
100
        $eventCategory = '',
101
        $eventAction = '',
102
        $eventLabel = '',
103
        $eventValue = 0
104
    ): Markup
105
    {
0 ignored issues
show
Coding Style introduced by
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Loading history...
106
        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...
107
            $url,
108
            $eventCategory,
109
            $eventAction,
110
            $eventLabel,
111
            $eventValue
112
        ));
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...
113
    }
114
115
    /**
116
     * Return whether we are running Craft 3.1 or later
117
     *
118
     * @return bool
119
     */
120
    public function craft31(): bool
121
    {
122
        return InstantAnalytics::$craft31;
123
    }
124
}
125