Passed
Push — main ( 81266e...c2a6e5 )
by Guillaume
03:04
created

VueJS::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 5
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
namespace PHPMV;
4
5
use PHPMV\js\JavascriptUtils;
6
7
/**
8
 * PHPMV$VueJS
9
 * This class is part of php-vuejs
10
 *
11
 * @author jc
12
 * @version 1.0.0
13
 *
14
 */
15
class VueJS extends AbstractVueJS {
16
17
	protected string $varName;
18
19 1
	public function __construct(array $configuration = ['el' => '#app'], string $varName = "app", bool $useVuetify = false) {
20 1
		parent::__construct($configuration);
21 1
		$this->varName = $varName;
22 1
		if ($useVuetify) {
23 1
			$this->configuration['vuetify'] = JavascriptUtils::removeQuotes("new Vuetify()");
24
		}
25 1
	}
26
27 1
	protected function generateVueObject(string $object): string {
28 1
		return "new Vue($object)";
29
	}
30
31 1
	public function __toString(): string {
32 1
		$script = $this->generateVueObject(JavascriptUtils::arrayToJsObject($this->configuration + $this->components + $this->directives + $this->filters + $this->mixins + $this->data + $this->computeds + $this->watchers + $this->hooks + $this->methods));
33 1
		$script = JavascriptUtils::declareVariable('const', $this->varName, $script);
34 1
		return $script;
35
	}
36
}