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

GoogleAnalytics::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
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