Passed
Push — master ( f4d59e...ca3fd6 )
by Chris
03:34
created

GoogleAnalytics   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OpenTickets\GoogleAnalytics\View\Helper;
6
7
use Zend\View\Helper\AbstractHelper;
8
9
final class GoogleAnalytics extends AbstractHelper
10
{
11
    /**
12
     * @var string
13
     */
14
    private $googleAnalyticsTrackingId;
15
16
    public function __construct(string $googleAnalyticsTrackingId)
17
    {
18
        $this->googleAnalyticsTrackingId = $googleAnalyticsTrackingId;
19
    }
20
21
    public function __invoke(): string
22
    {
23
        if ($this->googleAnalyticsTrackingId === '') {
24
            return '';
25
        }
26
        return $this->getView()->render('layout/google-analytics', [
27
            'trackingId' => $this->googleAnalyticsTrackingId,
28
        ]);
29
    }
30
}
31