PhpQuery   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A debug() 0 4 2
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 14 and the first side effect is on line 24.

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
use PhpQuery\Dom\DOMDocumentWrapper;
3
4
/**
5
 * Charset and document types test.
6
 *
7
 * Remember:
8
 * - never test charset with htmlentities ! Use htmlspecialchars (or define charset as parameter)
9
 *
10
 * TODO:
11
 * - document fragments tests (with all 4 charset scenarios)
12
 *
13
 */
14
class PhpQuery {
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...
15
	static $defaultDocumentID;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $defaultDocumentID.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

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

Loading history...
16
	static $debug = 0;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $debug.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

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

Loading history...
17
	static $documents = array();
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $documents.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

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

Loading history...
18
	static $defaultCharset = 'utf-8';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $defaultCharset.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

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

Loading history...
19
	static function debug($text) {
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...
20
		if (self::$debug)
21
			print var_dump($text);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($text); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
22
	}
23
}
24
require_once(__DIR__ . '/../../Dom/DOMDocumentWrapper.php');
25
PhpQuery::$debug = 2;
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...
26
27
/* ENCODINGS */
28
//print '<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-2">';
29
print '<meta http-equiv="Content-Type" content="text/html;charset=utf-8">';
30
31
/* HTML */
32
33
//$htmlIso = new DOMDocumentWrapper(
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% 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...
34
//	file_get_contents('document-types/document-iso88592.html')
35
//);
36
//$htmlIsoNoCharset = new DOMDocumentWrapper(
37
//	file_get_contents('document-types/document-iso88592-nocharset.html'),
38
//	'text/html;charset=iso-8859-2'
39
//);
40
$htmlUtf = new DOMDocumentWrapper(
41
	file_get_contents('document-types/document-utf8.html')
42
);
43
var_dump($htmlUtf->markup());
44
//$htmlUtfNoCharset = new DOMDocumentWrapper(
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% 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...
45
//	file_get_contents('document-types/document-utf8-nocharset.html'),
46
//	'text/html;charset=utf-8'
47
//);
48
//print htmlspecialchars($htmlIso->markup(
49
//	$htmlIso->document->getElementsByTagName('span'))
50
//);
51
//print htmlspecialchars($htmlIsoNoCharset->markup(
52
//	$htmlIsoNoCharset->document->getElementsByTagName('p'))
53
//);
54
//print htmlspecialchars($htmlUtf->markup());
55
//print htmlspecialchars($htmlUtfNoCharset->markup());
56
57
/* XML */
58
59
//$xmlIso = new DOMDocumentWrapper(
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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...
60
//	file_get_contents('document-types/document-iso88592.xml')
61
//);
62
//$xmlIsoNoCharset = new DOMDocumentWrapper(
63
//	file_get_contents('document-types/document-iso88592-nocharset.xml'),
64
//	'text/xml;charset=iso-8859-2'
65
//);
66
//$xmlUtf = new DOMDocumentWrapper(
67
//	file_get_contents('document-types/document-utf8.xml')
68
//);
69
//$xmlUtfNoCharset = new DOMDocumentWrapper(
70
//	file_get_contents('document-types/document-utf8-nocharset.xml'),
71
//	'text/xml;charset=utf-8'
72
//);
73
//print var_dump($xmlIso->markup(
74
//	$xmlIso->document->getElementsByTagName('step')->item(0)
75
//));
76
//print htmlspecialchars($xmlIsoNoCharset->markup());
77
//print htmlspecialchars($xmlUtf->markup());
78
//print htmlspecialchars($xmlUtfNoCharset->markup());
79
80
/* XHTML */
81
82
//$xhtmlIso = new DOMDocumentWrapper(
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% 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...
83
//	file_get_contents('document-types/document-iso88592.xhtml')
84
//);
85
//$xhtmlIsoNoCharset = new DOMDocumentWrapper(
86
//	file_get_contents('document-types/document-iso88592-nocharset.xhtml'),
87
//	'application/xhtml+xml;charset=iso-8859-2'
88
//);
89
//$xhtmlUtf = new DOMDocumentWrapper(
90
//	file_get_contents('document-types/document-utf8.xhtml')
91
//);
92
//$xhtmlUtfNoCharset = new DOMDocumentWrapper(
93
//	file_get_contents('document-types/document-utf8-nocharset.xhtml'),
94
//	'application/xhtml+xml'
95
//);
96
//print htmlspecialchars($xhtmlIso->markup());
97
//print var_dump($xhtmlIsoNoCharset->markup());
98
//print var_dump($xhtmlIsoNoCharset->markup(
99
//	$xhtmlIsoNoCharset->document->getElementsByTagName('p')
100
//));
101
//print var_dump($xhtmlUtf->markup());
102
//print var_dump($xhtmlUtf->markup(
103
//	$xhtmlUtf->document->getElementsByTagName('p')
104
//));
105
//print htmlspecialchars($xhtmlUtfNoCharset->markup());
106
107
/** FRAGMETNS **/
108
109
/* HTML fragment */
110
111
//$htmlFragmentUtf = new DOMDocumentWrapper(
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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...
112
//	file_get_contents('document-types/document-fragment-utf8.html')
113
//);
114
//$htmlFragmentUtf->markup();
115
//$htmlFragmentUtf->markup(
116
//	$htmlFragmentUtf->document->getElementsByTagName('span')
117
//);
118
119
/* XML fragment */
120
121
//$xmlFragmentUtf = new DOMDocumentWrapper(
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% 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...
122
//	file_get_contents('document-types/document-fragment-utf8.xml'),
123
//	'text/xml'nt var_dump($xhtmlFragmentUtf->document->saveXML());
124
//$xhtmlFragmentUtf->markup();
125
//$xhtmlFragmentUtf->markup(
126
//	$xhtmlFragmentUtf->document->getElementsByTagName('p')
127
//);
128
//);
129
//$xmlFragmentUtf->markup();
130
//$xmlFragmentUtf->markup(
131
//	$xmlFragmentUtf->document->getElementsByTagName('step')
132
//);
133
134
/* XHTML fragment */
135
136
//$xhtmlFragmentUtf = new DOMDocumentWrapper(
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
137
//	file_get_contents('document-types/document-fragment-utf8.xhtml'),
138
//	'application/xhtml+xml'
139
//);
140
//print var_dump($xhtmlFragmentUtf->document->saveXML());
141
//$xhtmlFragmentUtf->markup();
142
//$xhtmlFragmentUtf->markup(
143
//	$xhtmlFragmentUtf->document->getElementsByTagName('p')
144
//);
145
146
/* Test template */
147
//$result = pq('p:eq(1)');
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
148
//if ( $result->hasClass('newTitle') )
149
//	print "Test '{$testName}' PASSED :)";
150
//else
151
//	print "Test '{$testName}' <strong>FAILED</strong> !!! ";
152
//$result->dump();
153
//print "\n";