Total Complexity | 11 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class GlobalVueJS{ |
||
9 | |||
10 | private static ?GlobalVueJS $instance = null; |
||
11 | protected array $global; |
||
12 | |||
13 | protected function __construct() { |
||
14 | $this->global=[]; |
||
15 | } |
||
16 | |||
17 | public static function getInstance(): GlobalVueJS{ |
||
18 | if (!isset(self::$instance)) { |
||
19 | self::$instance = new GlobalVueJS(); |
||
20 | } |
||
21 | return self::$instance; |
||
|
|||
22 | } |
||
23 | |||
24 | public static function deleteInstance():void { |
||
25 | self::$instance = null; |
||
26 | } |
||
27 | |||
28 | public function addGlobalDirective(string $name,array $hookFunction):void { |
||
33 | } |
||
34 | |||
35 | public function addGlobalFilter(string $name,string $body, array $params = []):void { |
||
36 | $this->global[]="Vue.filter('".$name."',".JsUtils::generateFunction($body,$params,false).");"; |
||
37 | } |
||
38 | |||
39 | public function addGlobalObservable(string $varName, array $object){ |
||
40 | $this->global[]="const ".$varName." = Vue.observable(". JavascriptUtils::arrayToJsObject($object) .");"; |
||
41 | } |
||
42 | |||
43 | public function __toString():string { |
||
53 | } |
||
54 | } |