SendCommand::generate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 0
cts 5
cp 0
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace ByTIC\GoogleAnalytics\Tracking\Renderer\Script\AnalyticsJs;
4
5
use ByTIC\GoogleAnalytics\Tracking\Data\Tracker;
6
use ByTIC\GoogleAnalytics\Tracking\Renderer\Script\AnalyticsJs;
7
8
/**
9
 * Class SendCommand
10
 * @package ByTIC\GoogleAnalytics\Tracking\Renderer\Script\AnalyticsJs
11
 */
12 View Code Duplication
class SendCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @param Tracker $tracker
16
     * @param string $functionName
17
     * @return string
18
     */
19
    public static function generate($tracker, $functionName = AnalyticsJs::DEFAULT_FUNCTION_NAME)
20
    {
21
        $parameters = [];
0 ignored issues
show
Unused Code introduced by
$parameters is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
22
        $params = [
23
            $tracker->getCommandAlias() . 'send',
24
            'pageview',
25
        ];
26
27
        return MethodCall::generate($params, $functionName);
28
    }
29
}
30