Completed
Push — master ( 79b035...e37d9a )
by Jean-Christophe
03:44
created

JqueryActionsTrait::_exec()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
3
namespace Ajax\common\traits;
4
5
trait JqueryActionsTrait {
6
7
	/**
8
	 * Get or set the value of an attribute for the first element in the set of matched elements or set one or more attributes for every matched element.
9
	 * @param string $element
10
	 * @param string $attributeName
11
	 * @param string $value
12
	 * @param boolean $immediatly delayed if false
13
	 */
14 View Code Duplication
	public function _attr($element='this', $attributeName, $value="", $immediatly=false) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
16
		if (isset($value)) {
17
			$value=$this->_prep_value($value);
0 ignored issues
show
Bug introduced by
It seems like _prep_value() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
18
			$str="$({$element}).attr(\"$attributeName\",{$value});";
19
		} else
20
			$str="$({$element}).attr(\"$attributeName\");";
21
			if ($immediatly)
22
				$this->jquery_code_for_compile[]=$str;
0 ignored issues
show
Bug introduced by
The property jquery_code_for_compile does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
23
				return $str;
24
	}
25
26
	/**
27
	 * Insert content, specified by the parameter, after each element in the set of matched elements
28
	 * @param string $element
29
	 * @param string $value
30
	 * @param boolean $immediatly defers the execution if set to false
31
	 * @return string
32
	 */
33
	public function after($element='this', $value='', $immediatly=false){
34
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
35
		$value=$this->_prep_value($value);
0 ignored issues
show
Bug introduced by
It seems like _prep_value() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
36
		$str="$({$element}).after({$value});";
37
		if ($immediatly)
38
			$this->jquery_code_for_compile[]=$str;
39
			return $str;
40
	}
41
42
	/**
43
	 * Execute a jQuery animate action
44
	 *
45
	 * @param string $element element
46
	 * @param string|array $params One of 'slow', 'normal', 'fast', or time in milliseconds
47
	 * @param string $speed
48
	 * @param string $extra
49
	 * @param boolean $immediatly delayed if false
50
	 * @return string
51
	 */
52
	public function _animate($element='this', $params=array(), $speed='', $extra='', $immediatly=false) {
53
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
54
		$speed=$this->_validate_speed($speed);
0 ignored issues
show
Bug introduced by
It seems like _validate_speed() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
55
56
		$animations="\t\t\t";
57
		if (is_array($params)) {
58
			foreach ( $params as $param => $value ) {
59
				$animations.=$param.': \''.$value.'\', ';
60
			}
61
		}
62
		$animations=substr($animations, 0, -2); // remove the last ", "
63
64
		if ($speed!='') {
65
			$speed=', '.$speed;
66
		}
67
68
		if ($extra!='') {
69
			$extra=', '.$extra;
70
		}
71
72
		$str="$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");";
73
74
		if ($immediatly)
75
			$this->jquery_code_for_compile[]=$str;
76
			return $str;
77
	}
78
79
	// --------------------------------------------------------------------
80
81
	/**
82
	 * Execute a jQuery hide action
83
	 *
84
	 * @param string $element element
85
	 * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds
86
	 * @param string $callback Javascript callback function
87
	 * @param boolean $immediatly delayed if false
88
	 * @return string
89
	 */
90 View Code Duplication
	public function _fadeIn($element='this', $speed='', $callback='', $immediatly=false) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
91
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
92
		$speed=$this->_validate_speed($speed);
0 ignored issues
show
Bug introduced by
It seems like _validate_speed() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
93
94
		if ($callback!='') {
95
			$callback=", function(){\n{$callback}\n}";
96
		}
97
98
		$str="$({$element}).fadeIn({$speed}{$callback});";
99
100
		if ($immediatly)
101
			$this->jquery_code_for_compile[]=$str;
102
			return $str;
103
	}
104
105
	// --------------------------------------------------------------------
106
107
	/**
108
	 * Execute a jQuery fadeOut action
109
	 *
110
	 * @param string $element element
111
	 * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds
112
	 * @param string $callback Javascript callback function
113
	 * @param boolean $immediatly delayed if false
114
	 * @return string
115
	 */
116 View Code Duplication
	public function _fadeOut($element='this', $speed='', $callback='', $immediatly=false) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
117
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
118
		$speed=$this->_validate_speed($speed);
0 ignored issues
show
Bug introduced by
It seems like _validate_speed() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
119
120
		if ($callback!='') {
121
			$callback=", function(){\n{$callback}\n}";
122
		}
123
124
		$str="$({$element}).fadeOut({$speed}{$callback});";
125
126
		if ($immediatly)
127
			$this->jquery_code_for_compile[]=$str;
128
			return $str;
129
	}
130
131
	// --------------------------------------------------------------------
132
133
	/**
134
	 * Execute a jQuery hide action
135
	 *
136
	 * @param string $element element
137
	 * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds
138
	 * @param string $callback Javascript callback function
139
	 * @param boolean $immediatly delayed if false
140
	 * @return string
141
	 */
142 View Code Duplication
	public function _hide($element='this', $speed='', $callback='', $immediatly=false) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
143
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
144
		$speed=$this->_validate_speed($speed);
0 ignored issues
show
Bug introduced by
It seems like _validate_speed() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
145
146
		if ($callback!='') {
147
			$callback=", function(){\n{$callback}\n}";
148
		}
149
150
		$str="$({$element}).hide({$speed}{$callback});";
151
152
		if ($immediatly)
153
			$this->jquery_code_for_compile[]=$str;
154
			return $str;
155
	}
156
157
	// --------------------------------------------------------------------
158
159
	// --------------------------------------------------------------------
160
161
	/**
162
	 * Execute a jQuery slideUp action
163
	 *
164
	 * @param string $element element
165
	 * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds
166
	 * @param string $callback Javascript callback function
167
	 * @param boolean $immediatly delayed if false
168
	 * @return string
169
	 */
170 View Code Duplication
	public function _slideUp($element='this', $speed='', $callback='', $immediatly=false) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
171
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
172
		$speed=$this->_validate_speed($speed);
0 ignored issues
show
Bug introduced by
It seems like _validate_speed() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
173
174
		if ($callback!='') {
175
			$callback=", function(){\n{$callback}\n}";
176
		}
177
178
		$str="$({$element}).slideUp({$speed}{$callback});";
179
180
		if ($immediatly)
181
			$this->jquery_code_for_compile[]=$str;
182
			return $str;
183
	}
184
185
	// --------------------------------------------------------------------
186
187
	/**
188
	 * Execute a jQuery slideDown action
189
	 *
190
	 * @param string $element element
191
	 * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds
192
	 * @param string $callback Javascript callback function
193
	 * @param boolean $immediatly delayed if false
194
	 * @return string
195
	 */
196 View Code Duplication
	public function _slideDown($element='this', $speed='', $callback='', $immediatly=false) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
197
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
198
		$speed=$this->_validate_speed($speed);
0 ignored issues
show
Bug introduced by
It seems like _validate_speed() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
199
200
		if ($callback!='') {
201
			$callback=", function(){\n{$callback}\n}";
202
		}
203
204
		$str="$({$element}).slideDown({$speed}{$callback});";
205
206
		if ($immediatly)
207
			$this->jquery_code_for_compile[]=$str;
208
			return $str;
209
	}
210
211
	// --------------------------------------------------------------------
212
213
	/**
214
	 * Execute a jQuery slideToggle action
215
	 *
216
	 * @param string $element element
217
	 * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds
218
	 * @param string $callback Javascript callback function
219
	 * @param boolean $immediatly delayed if false
220
	 * @return string
221
	 */
222 View Code Duplication
	public function _slideToggle($element='this', $speed='', $callback='', $immediatly=false) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
223
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
224
		$speed=$this->_validate_speed($speed);
0 ignored issues
show
Bug introduced by
It seems like _validate_speed() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
225
226
		if ($callback!='') {
227
			$callback=", function(){\n{$callback}\n}";
228
		}
229
230
		$str="$({$element}).slideToggle({$speed}{$callback});";
231
232
		if ($immediatly)
233
			$this->jquery_code_for_compile[]=$str;
234
			return $str;
235
	}
236
237
	// --------------------------------------------------------------------
238
239
	/**
240
	 * Outputs a jQuery toggle event
241
	 *
242
	 * @param string $element element
243
	 * @param boolean $immediatly delayed if false
244
	 * @return string
245
	 */
246 View Code Duplication
	public function _toggle($element='this', $immediatly=false) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
247
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
248
		$str="$({$element}).toggle();";
249
250
		if ($immediatly)
251
			$this->jquery_code_for_compile[]=$str;
252
			return $str;
253
	}
254
255
	// --------------------------------------------------------------------
256
257
	/**
258
	 * Execute all handlers and behaviors attached to the matched elements for the given event.
259
	 * @param string $element
260
	 * @param string $event
261
	 * @param boolean $immediatly delayed if false
262
	 */
263 View Code Duplication
	public function _trigger($element='this', $event='click', $immediatly=false) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
264
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
265
		$str="$({$element}).trigger(\"$event\");";
266
267
		if ($immediatly)
268
			$this->jquery_code_for_compile[]=$str;
269
			return $str;
270
	}
271
272
	// --------------------------------------------------------------------
273
274
	/**
275
	 * Execute a jQuery show action
276
	 *
277
	 * @param string $element element
278
	 * @param string $speed One of 'slow', 'normal', 'fast', or time in milliseconds
279
	 * @param string $callback Javascript callback function
280
	 * @param boolean $immediatly delayed if false
281
	 * @return string
282
	 */
283 View Code Duplication
	public function _show($element='this', $speed='', $callback='', $immediatly=false) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
284
		$element=$this->_prep_element($element);
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
285
		$speed=$this->_validate_speed($speed);
0 ignored issues
show
Bug introduced by
It seems like _validate_speed() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
286
287
		if ($callback!='') {
288
			$callback=", function(){\n{$callback}\n}";
289
		}
290
291
		$str="$({$element}).show({$speed}{$callback});";
292
293
		if ($immediatly)
294
			$this->jquery_code_for_compile[]=$str;
295
			return $str;
296
	}
297
298
	/**
299
	 * Places a condition
300
	 * @param string $condition
301
	 * @param string $jsCodeIfTrue
302
	 * @param string $jsCodeIfFalse
303
	 * @param boolean $immediatly delayed if false
304
	 * @return string
305
	 */
306
	public function _condition($condition, $jsCodeIfTrue, $jsCodeIfFalse=null, $immediatly=false) {
307
		$str="if(".$condition."){".$jsCodeIfTrue."}";
308
		if (isset($jsCodeIfFalse)) {
309
			$str.="else{".$jsCodeIfFalse."}";
310
		}
311
312
		if ($immediatly)
313
			$this->jquery_code_for_compile[]=$str;
314
			return $str;
315
	}
316
317
	// ------------------------------------------------------------------------
318
	/**
319
	 * Call the JQuery method $jqueryCall on $element with parameters $param
320
	 * @param string $element
321
	 * @param string $jqueryCall
322
	 * @param mixed $param
323
	 * @param string $jsCallback javascript code to execute after the jquery call
324
	 * @param boolean $immediatly
325
	 * @return string
326
	 */
327
	public function _doJQuery($element, $jqueryCall, $param="", $jsCallback="", $immediatly=false) {
328
		$param=$this->_prep_value($param);
0 ignored issues
show
Bug introduced by
It seems like _prep_value() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
329
		$callback="";
330
		if ($jsCallback!="")
331
			$callback=", function(event){\n{$jsCallback}\n}";
332
			$script="$(".$this->_prep_element($element).").".$jqueryCall."(".$param.$callback.");\n";
0 ignored issues
show
Bug introduced by
It seems like _prep_element() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
333
			if ($immediatly)
334
				$this->jquery_code_for_compile[]=$script;
335
				return $script;
336
	}
337
338
	/**
339
	 *
340
	 * @param string $event
341
	 * @param string $element
342
	 * @param string $elementToModify
343
	 * @param string $jqueryCall
344
	 * @param string|array $param
345
	 * @param boolean $preventDefault
346
	 * @param boolean $stopPropagation
347
	 * @param string $jsCallback javascript code to execute after the jquery call
348
	 * @param boolean $immediatly
349
	 * @return string
350
	 */
351
	public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) {
352
		return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly);
0 ignored issues
show
Bug introduced by
It seems like _add_event() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
353
	}
354
355
	/**
356
	 * Execute the code $js
357
	 * @param string $js Code to execute
358
	 * @param boolean $immediatly diffère l'exécution si false
359
	 * @return String
360
	 */
361
	public function _exec($js, $immediatly=false) {
362
		$script=$js."\n";
363
		if ($immediatly)
364
			$this->jquery_code_for_compile[]=$script;
365
			return $script;
366
	}
367
368
	/**
369
	 *
370
	 * @param string $element
371
	 * @param string $event
372
	 * @param string $js Code to execute
373
	 * @param boolean $preventDefault
374
	 * @param boolean $stopPropagation
375
	 * @param boolean $immediatly
376
	 * @return String
377
	 */
378
	public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false,$immediatly=true) {
379
		return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation,$immediatly);
0 ignored issues
show
Bug introduced by
It seems like _add_event() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
380
	}
381
}