Passed
Pull Request — develop ( #58 )
by
unknown
32:22 queued 14:42
created

Js::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
ccs 0
cts 4
cp 0
crap 2
1
<?php
2
/**
3
 * @link http://www.newicon.net/neon
4
 * @copyright Copyright (c) 16/09/2016 Newicon Ltd
5
 * @license http://www.newicon.net/neon/license/
6
 */
7
8
namespace neon\core\widgets;
9
10
use yii\base\Widget;
11
use \neon\core\web\View;
12
13
class Js extends Widget
14
{
15
	public $position = View::POS_READY;
16
17
	public function init()
18
	{
19
		parent::init();
20
		ob_start();
21
	}
22
23
	public function run()
24
	{
25
		$jsScript = ob_get_clean();
26
		// remove script tags
27
		$jsScript = str_replace(['<script>', '</script>'], '', $jsScript);
28
		$this->view->registerJs($jsScript, $this->position);
29
	}
30
}