Passed
Push — main ( 41a3a8...4b84ad )
by Guillaume
02:22
created

VueJS   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 96.15%

Importance

Changes 7
Bugs 0 Features 0
Metric Value
eloc 21
dl 0
loc 43
ccs 25
cts 26
cp 0.9615
rs 10
c 7
b 0
f 0
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A __toString() 0 11 2
A getConfiguration() 0 2 1
A getUseAxios() 0 2 1
A setUseAxios() 0 2 1
A setConfiguration() 0 2 1
1
<?php
2
namespace PHPMV;
3
4
use PHPMV\js\JavascriptUtils;
5
use PHPMV\utils\JsUtils;
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 $useAxios;
18
19
	protected $configuration;
20
21 9
	public function __construct(string $app = "#app", bool $vuetify = false, bool $useAxios = false) {
22 9
		parent::__construct();
23 9
		$this->configuration['el'] = '"' . $app . '"';
24 9
		if ($vuetify) {
25 9
			$this->configuration['vuetify'] = "new Vuetify()";
26
		}
27
		;
28 9
		$this->useAxios = $useAxios;
29 9
	}
30
31 1
	public function __toString(): string {
32 1
		$script = "";
33 1
		if ($this->useAxios) {
34
			$script .= "Vue.prototype.\$http = axios;\n";
35
		}
36 1
		$script .= "const app=new Vue(";
37 1
		$script .= JavascriptUtils::arrayToJsObject($this->configuration + $this->data + $this->methods + $this->watchers + $this->computeds + $this->hooks);
38 1
		$script = JsUtils::cleanJSONFunctions($script);
39 1
		$script .= ")";
40 1
		$script = JavascriptUtils::wrapScript($script);
41 1
		return $script;
42
	}
43
44 1
	public function getUseAxios(): bool {
45 1
		return $this->useAxios;
46
	}
47
48 1
	public function setUseAxios(bool $useAxios): void {
49 1
		$this->useAxios = $useAxios;
50 1
	}
51
52 1
	public function getConfiguration(): array {
53 1
		return $this->configuration;
54
	}
55
56 1
	public function setConfiguration(array $configuration): void {
57 1
		$this->configuration = $configuration;
58 1
	}
59
}
60
$vue=new VueJS("#app",false,false);