Passed
Push — main ( 1eb874...c550ce )
by Guillaume
02:31
created

VueJS::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 3
dl 0
loc 6
ccs 5
cts 6
cp 0.8333
crap 2.0185
rs 10
c 1
b 0
f 0
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 array $configuration;
18
	protected string $varName;
19
20 1
	public function __construct(array $configuration = ['el' => '#app'], string $varName = "app", bool $useVuetify = false) {
21 1
		parent::__construct();
22 1
		$this->varName = $varName;
23 1
		$this->configuration = $configuration;
24 1
		if ($useVuetify) {
25
			$this->configuration['vuetify'] = "new Vuetify()";
26
		}
27 1
	}
28
29 1
	protected function generateVueObject(string $object): string {
30 1
		return "new Vue(" . $object . ")";
31
	}
32
33 1
	public function __toString(): string {
34 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));
35 1
		$script = JavascriptUtils::declareVariable('const', $this->varName, $script);
0 ignored issues
show
Bug introduced by
The method declareVariable() does not exist on PHPMV\js\JavascriptUtils. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
		/** @scrutinizer ignore-call */ 
36
  $script = JavascriptUtils::declareVariable('const', $this->varName, $script);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36 1
		return $script;
37
	}
38
}