callbackClass   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A staticMethodCallback() 0 3 1
A methodCallback() 0 3 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 6 and the first side effect is on line 2.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
require_once('../PhpQuery/PhpQuery.php');
3
PhpQuery::$debug = true;
0 ignored issues
show
Bug introduced by
The property debug cannot be accessed from this context as it is declared private in class PhpQuery.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
Documentation Bug introduced by
The property $debug was declared of type integer, but true is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
4
5
// CALLBACKS
6
class callbackClass {
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...
7
	static function staticMethodCallback($node) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
8
		pq($node)->addClass('newClass');
9
	}
10
	function methodCallback($node) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
11
		pq($node)->addClass('newClass');
12
	}
13
}
14
function functionCallback($node) {
15
	pq($node)->addClass('newClass');
16
}
17
$testResult = array(
18
	'li.newClass',
19
	'li#testID.newClass',
20
	'li.newClass',
21
	'li#i_have_nested_list.newClass',
22
	'li.nested.newClass',
23
	'li.second.newClass',
24
);
25
$tests = array(
26
	'functionCallback',
27
	array('callbackClass', 'staticMethodCallback'),
28
	array(new callbackClass, 'methodCallback')
29
);
30
foreach($tests as $test) {
31
	$result = PhpQuery::newDocumentFile('test.html')
0 ignored issues
show
Bug introduced by
The method newDocumentFile() does not seem to exist on object<PhpQuery>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
		->find('li')
33
			->each($test);
34
	$testName = is_array($test)
35
		? $test[1]
36
		: $test;
37 View Code Duplication
	if ( $result->whois() == $testResult )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
38
		print "Test '$testName' PASSED :)";
39
	else {
40
		print "Test '$testName' <strong>FAILED</strong> !!! ";
41
		print "<pre>";
42
		print_r($result->whois());
43
		print "</pre>\n";
44
	}
45
	print "\n";
46
}
47
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...