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

VueJS   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 8
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 20
ccs 12
cts 12
cp 1
rs 10
c 8
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A __toString() 0 4 1
A generateVueObject() 0 2 1
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
}