PhpQuery_Plugin_example   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A example() 0 9 1
A helperFunction() 0 4 1
1
<?php
2
/**
3
 * Example of PhpQuery plugin.
4
 *
5
 * Load it like this:
6
 * PhpQuery::plugin('example')
7
 * PhpQuery::plugin('example', 'example.php')
8
 * pq('ul')->plugin('example')
9
 * pq('ul')->plugin('example', 'example.php')
10
 *
11
 * Plugin classes are never intialized, just method calls are forwarded
12
 * in static way from PhpQuery.
13
 *
14
 * Have fun writing plugins :)
15
 */
16
17
/**
18
 * PhpQuery plugin class extending PhpQuery object.
19
 * Methods from this class are callable on every PhpQuery object.
20
 *
21
 * Class name prefix '\PhpQuery\Plugin\' must be preserved.
22
 */
23
abstract class PhpQuery_Plugin_example {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
24
	/**
25
	 * Limit binded methods.
26
	 *
27
	 * null means all public.
28
	 * array means only specified ones.
29
	 *
30
	 * @var array|null
31
	 */
32
	public static $PhpQueryMethods = null;
33
	/**
34
	 * Enter description here...
35
	 *
36
	 * @param \PhpQueryObject $self
37
	 */
38
	public static function example($self, $arg1) {
0 ignored issues
show
Unused Code introduced by
The parameter $arg1 is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
		// this method can be called on any PhpQuery object, like this:
40
		// pq('div')->example('$arg1 Value')
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
42
		// do something
43
		$self->append('Im just an example !');
44
		// change stack of result object
45
		return $self->find('div');
46
	}
47
	protected static function helperFunction() {
48
		// this method WONT be avaible as PhpQuery method,
49
		// because it isn't publicly callable
50
	}
51
}
52
53
/**
54
 * PhpQuery plugin class extending PhpQuery static namespace.
55
 * Methods from this class are callable as follows:
56
 * PhpQuery::$plugins->staticMethod()
57
 *
58
 * Class name prefix 'PhpQueryPlugin_' must be preserved.
59
 */
60
abstract class PhpQueryPlugin_example {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
61
	/**
62
	 * Limit binded methods.
63
	 *
64
	 * null means all public.
65
	 * array means only specified ones.
66
	 *
67
	 * @var array|null
68
	 */
69
	public static $PhpQueryMethods = null;
70
	public static function staticMethod() {
71
		// this method can be called within PhpQuery class namespace, like this:
72
		// PhpQuery::$plugins->staticMethod()
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
73
	}
74
}