Passed
Push — main ( f5d3c8...cedc07 )
by Guillaume
02:48
created

VueJS   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 8
Bugs 0 Features 0
Metric Value
eloc 21
c 8
b 0
f 0
dl 0
loc 42
ccs 26
cts 26
cp 1
rs 10
wmc 8

6 Methods

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