Test Failed
Push — main ( bd1d3b...4ff84d )
by Guillaume
02:12
created

VueJSComponent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 7 1
A setProps() 0 2 1
1
<?php
2
namespace PHPMV;
3
4
use PHPMV\js\JavascriptUtils;
5
use PHPMV\utils\JsUtils;
6
7
class VueJSComponent extends AbstractVueJS{
8
    protected $name;
9
    protected $props=["props"=>[]];
10
    protected $template;
11
    
12
    public function __construct(string $template) {
13
        parent::__construct();
14
        $this->template["template"]="'".str_replace(["\n","\r","\t"]," ",(file_get_contents($template.'.html',FILE_USE_INCLUDE_PATH))."'");
0 ignored issues
show
Bug introduced by
PHPMV\FILE_USE_INCLUDE_PATH of type integer is incompatible with the type boolean expected by parameter $use_include_path of file_get_contents(). ( Ignorable by Annotation )

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

14
        $this->template["template"]="'".str_replace(["\n","\r","\t"]," ",(file_get_contents($template.'.html',/** @scrutinizer ignore-type */ FILE_USE_INCLUDE_PATH))."'");
Loading history...
15
        $this->name=$template;
16
    }
17
    
18
    public function setProps(string ...$name):void {
19
        $this->props["props"]=$name;
20
    }
21
    
22
    public function create():string {
23
        $script="Vue.component('".$this->name."',";
24
        $script.=JavascriptUtils::arrayToJsObject($this->props + $this->data + $this->methods + $this->computeds + $this->watchers + $this->hooks + $this->template);
0 ignored issues
show
Bug introduced by
The method arrayToJsObject() 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

24
        $script.=JavascriptUtils::/** @scrutinizer ignore-call */ arrayToJsObject($this->props + $this->data + $this->methods + $this->computeds + $this->watchers + $this->hooks + $this->template);

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...
25
        $script=JsUtils::cleanJSONFunctions($script);
0 ignored issues
show
Bug Best Practice introduced by
The method PHPMV\utils\JsUtils::cleanJSONFunctions() is not static, but was called statically. ( Ignorable by Annotation )

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

25
        /** @scrutinizer ignore-call */ 
26
        $script=JsUtils::cleanJSONFunctions($script);
Loading history...
26
        $script.=")";
27
        file_put_contents($this->name.".js", $script);
28
        return $script;
29
    }
30
}