Completed
Branchmaster (dec762)
created

Analytics::renderStart()   A

↳ Parent: Analytics

Complexity

Conditions 2
Paths 2

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 12
Code Lines 8

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 0
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace Redaxscript\Modules\Analytics;
3
4
use Redaxscript\Module;
5
use Redaxscript\Head;
6
use Redaxscript\Registry;
7
8
/**
9
 * integrate google analytics
10
 *
11
 * @since 2.2.0
12
 *
13
 * @package Redaxscript
14
 * @category Modules
15
 * @author Henry Ruhs
16
 */
17
18
class Analytics extends Module
19
{
20
	/**
21
	 * array of the module
22
	 *
23
	 * @var array
24
	 */
25
26
	protected static $_moduleArray =
27
	[
28
		'name' => 'Analytics',
29
		'alias' => 'Analytics',
30
		'author' => 'Redaxmedia',
31
		'description' => 'Integrate Google Analytics',
32
		'version' => '3.0.0'
33
	];
34
35
	/**
36
	 * renderStart
37
	 *
38
	 * @since 3.0.0
39
	 */
40
41
	public static function renderStart()
42
	{
43
		if (Registry::get('loggedIn') !== Registry::get('token'))
44
		{
45
			$script = Head\Script::getInstance();
46
			$script
47
				->init('foot')
48
				->appendFile('//google-analytics.com/analytics.js')
49
				->appendFile('modules/Analytics/assets/scripts/init.js')
50
				->appendFile('modules/Analytics/assets/scripts/analytics.js');
51
		}
52
	}
53
}
54