Test Failed
Push — main ( d7f1b4...976a1c )
by Guillaume
02:42
created

VueManager::addVue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
1
<?php
2
namespace PHPMV;
3
4
use PHPMV\js\JavascriptUtils;
5
6
class VueManager{
7
8
    private static ?VueManager $instance = null;
9
    protected array $imports;
10
    protected array $vues;
11
12
    protected function __construct() {
13
        $this->imports = [];
14
        $this->vues = [];
15
    }
16
17
    public static function getInstance():VueManager {
18
        if (!isset(self::$instance)) {
19
            self::$instance = new VueManager();
20
        }
21
        return self::$instance;
0 ignored issues
show
Bug Best Practice introduced by
The expression return self::instance could return the type null which is incompatible with the type-hinted return PHPMV\VueManager. Consider adding an additional type-check to rule them out.
Loading history...
22
    }
23
24
    public function addImport($import):void {
25
        $this->imports[] = $import;
26
    }
27
28
    public function addVue(VueJS $vue):void {
29
        $this->vues[] = $vue;
30
    }
31
32
    public function __toString():string {
33
        $script = implode("\n",$this->imports);
34
        $script .= implode("\n",$this->vues);
35
        return JavascriptUtils::wrapScript($script);
36
    }
37
}