WebLibrary   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 160
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
wmc 12
lcom 2
cbo 0
dl 0
loc 160
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getJsFiles() 0 3 1
A setJsFiles() 0 3 1
A addJsFile() 0 3 1
A getCssFiles() 0 3 1
A setCssFiles() 0 3 1
A addCssFile() 0 3 1
A getDependencies() 0 3 1
A getFeatures() 0 3 1
A setDependencies() 0 3 1
A isAsync() 0 3 1
A setIsAsync() 0 3 1
1
<?php
2
namespace Mouf\Html\Utils\WebLibraryManager;
3
4
/**
5
 * A WebLibrary represents a set of CSS and JS files that can be integrated into your web application.
6
 * 
7
 * @author David Négrier
8
 */
9
class WebLibrary implements WebLibraryInterface {
10
	
11
	
12
	/**
13
	 * List of JS files to add in header.
14
     * If you don't specify http:// or https:// and if your URL does not start with /, the file is considered to be relative to ROOT_URL.
15
     * 
16
	 * @var array<string>
17
	 */
18
	private $jsFiles = array();
19
20
	/**
21
	 * List of CSS files to add in header.
22
	 * If you don't specify http:// or https:// and if your URL does not start with /, the file is considered to be relative to ROOT_URL.
23
	 *
24
	 * @var array<string>
25
	 */
26
	private $cssFiles = array();
27
28
	/**
29
	 * List of libraries this library depends on.
30
	 * 
31
	 * @var array<WebLibraryInterface>
32
	 */
33
	private $dependencies = array();
34
35
    /**
36
     * Boolean whether the dependencies are called asynchronously
37
     *
38
     * @var bool
39
     */
40
    private $async = false;
41
	
42
	
43
	/**
44
	 * Constructor
45
	 * 
46
	 * @param string[] $jsFiles List of JS files to add in header. If you don't specify http:// or https:// and if your URL does not start with /, the file is considered to be relative to ROOT_URL.
47
	 * @param string[] $cssFiles List of CSS files to add in header. If you don't specify http:// or https:// and if your URL does not start with /, the file is considered to be relative to ROOT_URL.
48
	 */
49
	
50
	public function __construct($jsFiles = array(), $cssFiles = array() ) {
51
		$this->jsFiles= $jsFiles;
52
		$this->cssFiles = $cssFiles;
53
	}
54
	
55
	/**
56
	 * Returns an array of Javascript files to be included for this library.
57
	 * 
58
	 * @return array<string>
59
	 */
60
	public function getJsFiles() {
61
		return $this->jsFiles;
62
	}
63
	
64
	/**
65
	 * List of JS files to put in the web library.
66
	 * <p>If you don't specify http:// or https:// and if the file does not start with /, the file is considered to be relative to ROOT_URL.</p>
67
	 * <div class="info">It is a good practice to make sure the file does not start with /, http:// or https:// (unless you are using a CDN).</div>
68
     * 
69
	 * @Property
70
	 * @param array<string> $jsFiles
71
	 */
72
	public function setJsFiles($jsFiles) {
73
		$this->jsFiles = $jsFiles;
74
	}
75
	
76
	/**
77
	 * Adds a JS file to the web library.
78
	 * <p>If you don't specify http:// or https:// and if the file does not start with /, the file is considered to be relative to ROOT_URL.</p>
79
	 * <div class="info">It is a good practice to make sure the file does not start with /, http:// or https:// (unless you are using a CDN).</div>
80
	 * 
81
	 * @param string $jsFile
82
	 */
83
	public function addJsFile($jsFile) {
84
		$this->jsFiles[] = $jsFile;
85
	}
86
	
87
	/**
88
	 * Returns an array of CSS files to be included for this library.
89
	 *
90
	 * @return array<string>
91
	 */
92
	public function getCssFiles() {
93
		return $this->cssFiles;
94
	}
95
	
96
	/**
97
	 * List of CSS files to add in web library.
98
	 * <p>If you don't specify http:// or https:// and if the file does not start with /, the file is considered to be relative to ROOT_URL.</p>
99
	 * <div class="info">It is a good practice to make sure the file does not start with /, http:// or https:// (unless you are using a CDN).</div>
100
	 *
101
	 * @Property
102
	 * @param array<string> $cssFiles
103
	 */
104
	public function setCssFiles($cssFiles) {
105
		$this->cssFiles = $cssFiles;
106
	}
107
	
108
	/**
109
	 * Adds a CSS file to the web library.
110
	 * <p>If you don't specify http:// or https:// and if the file does not start with /, the file is considered to be relative to ROOT_URL.</p>
111
	 * <div class="info">It is a good practice to make sure the file does not start with /, http:// or https:// (unless you are using a CDN).</div>
112
	 * 
113
	 * @param string $jsFile
0 ignored issues
show
Bug introduced by
There is no parameter named $jsFile. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
114
	 */
115
	public function addCssFile($cssFile) {
116
		$this->cssFiles[] = $cssFile;
117
	}
118
	
119
	/**
120
	 * Returns a list of libraries that must be included before this library is included.
121
	 *
122
	 * @return array<WebLibraryInterface>
123
	 */
124
	public function getDependencies() {
125
		return $this->dependencies;
126
	}
127
	
128
	/**
129
	 * Returns a list of features provided by this library.
130
	 * A feature is typically a string describing what the file contains.
131
	 *
132
	 * For instance, an object representing the JQuery library would provide the "jquery" feature.
133
	 *
134
	 * @return array<string>
135
	 */
136
	public function getFeatures() {
137
		throw new \Exception("Not implemented yet!");
138
	}
139
	
140
	/**
141
	 * The list of all libraries that are needed for this library
142
	 * 
143
	 * @Property
144
	 * @param array<WebLibraryInterface> $libraries
145
	 */
146
	public function setDependencies($libraries) {
147
		$this->dependencies = $libraries;
148
	}
149
150
    /**
151
     * Returns if the dependencies are loaded asynchronously
152
     *
153
     * @return bool
154
     */
155
    public function isAsync() {
156
        return $this->async;
157
    }
158
159
    /**
160
     * Set if the dependencies are loaded asynchronously
161
     *
162
     * @Property
163
     * @param bool $async
164
     */
165
    public function setIsAsync($async) {
166
        $this->async = $async;
167
    }
168
}