Passed
Push — main ( 8a2c2c...f2e444 )
by Guillaume
02:30
created

VueJS   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 93.1%

Importance

Changes 8
Bugs 0 Features 0
Metric Value
eloc 24
dl 0
loc 48
ccs 27
cts 29
cp 0.931
rs 10
c 8
b 0
f 0
wmc 10

6 Methods

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