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

VueJS::generateVueObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
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
}