@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | { |
64 | 64 | $c = $this->owner; |
65 | 65 | $model = $c->customisedObject ? $c->customisedObject : $c->data(); |
66 | - if (! $model) { |
|
66 | + if (!$model) { |
|
67 | 67 | return null; |
68 | 68 | } |
69 | 69 | |
70 | 70 | $field = $this->_contentField(); |
71 | - if (! $model->hasField($field)) { |
|
71 | + if (!$model->hasField($field)) { |
|
72 | 72 | return null; |
73 | 73 | } |
74 | 74 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function getAutotoc() |
89 | 89 | { |
90 | 90 | $tocifier = $this->_getTocifier(); |
91 | - if (! $tocifier) { |
|
91 | + if (!$tocifier) { |
|
92 | 92 | return null; |
93 | 93 | } |
94 | 94 |
@@ -89,7 +89,7 @@ |
||
89 | 89 | |
90 | 90 | $body = $doc->getElementsByTagName('body')->item(0); |
91 | 91 | $this->_html = str_replace(array('<body>', '</body>'), '', |
92 | - $doc->saveHTML($body)); |
|
92 | + $doc->saveHTML($body)); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | private function _dumpBranch($node, $indent = '') |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // Consider this node a potential dangling parent |
84 | - $this->_dangling[$level] =& $node; |
|
84 | + $this->_dangling[$level] = & $node; |
|
85 | 85 | |
86 | 86 | return $node; |
87 | 87 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | private function _processDocument($doc) |
95 | 95 | { |
96 | - $this->_tree =& $this->_newNode(self::$prefix, '', 0); |
|
96 | + $this->_tree = & $this->_newNode(self::$prefix, '', 0); |
|
97 | 97 | $n = 1; |
98 | 98 | |
99 | 99 | $xpath = new DOMXPath($doc); |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | foreach ($xpath->query($query) as $h) { |
103 | 103 | $text = $this->_getPlainText($h); |
104 | 104 | $level = (int) substr($h->tagName, 1); |
105 | - $id = self::$prefix . $n; |
|
105 | + $id = self::$prefix.$n; |
|
106 | 106 | ++$n; |
107 | 107 | |
108 | 108 | // Build the tree |
109 | - $parent =& $this->_getParent($level); |
|
110 | - $node =& $this->_newNode($id, $text, $level); |
|
111 | - if (! isset($parent['children'])) { |
|
109 | + $parent = & $this->_getParent($level); |
|
110 | + $node = & $this->_newNode($id, $text, $level); |
|
111 | + if (!isset($parent['children'])) { |
|
112 | 112 | $parent['children'] = array(); |
113 | 113 | } |
114 | - $parent['children'][] =& $node; |
|
114 | + $parent['children'][] = & $node; |
|
115 | 115 | |
116 | 116 | // Prepend the anchor |
117 | 117 | $anchor = $doc->createElement('a'); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | private function _dumpBranch($node, $indent = '') |
135 | 135 | { |
136 | - echo $indent . $node['title'] . "\n"; |
|
136 | + echo $indent.$node['title']."\n"; |
|
137 | 137 | if (isset($node['children'])) { |
138 | 138 | foreach ($node['children'] as &$child) { |
139 | 139 | $this->_dumpBranch($child, "$indent\t"); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | public function process() |
176 | 176 | { |
177 | 177 | // Check if $this->_raw_html is valid |
178 | - if (! is_string($this->_raw_html) || empty($this->_raw_html)) { |
|
178 | + if (!is_string($this->_raw_html) || empty($this->_raw_html)) { |
|
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | // Parse the HTML into a DOMDocument tree |
188 | 188 | $doc = new DOMDocument(); |
189 | - if (! @$doc->loadHTML($html)) { |
|
189 | + if (!@$doc->loadHTML($html)) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | |
23 | 23 | public function testHtml() |
24 | 24 | { |
25 | - $tocifier = new Tocifier(file_get_contents(__DIR__ . '/test1')); |
|
25 | + $tocifier = new Tocifier(file_get_contents(__DIR__.'/test1')); |
|
26 | 26 | $this->assertEquals($tocifier->getHtml(), ''); |
27 | 27 | $this->assertTrue($tocifier->process()); |
28 | - $this->assertStringEqualsFile(__DIR__ . '/html1', $tocifier->getHtml()); |
|
28 | + $this->assertStringEqualsFile(__DIR__.'/html1', $tocifier->getHtml()); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public function testTOC() |
32 | 32 | { |
33 | - $tocifier = new Tocifier(file_get_contents(__DIR__ . '/test1')); |
|
33 | + $tocifier = new Tocifier(file_get_contents(__DIR__.'/test1')); |
|
34 | 34 | $this->assertEquals($tocifier->getTOC(), array()); |
35 | 35 | $this->assertTrue($tocifier->process()); |
36 | 36 | $this->assertNotNull($tocifier->getTOC()); |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | ob_start(); |
39 | 39 | $tocifier->dumpTOC(); |
40 | 40 | $returned = ob_get_clean(); |
41 | - $this->assertStringEqualsFile(__DIR__ . '/toc1', $returned); |
|
41 | + $this->assertStringEqualsFile(__DIR__.'/toc1', $returned); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | public function testDataHideFromTOC() |
45 | 45 | { |
46 | - $tocifier = new Tocifier(file_get_contents(__DIR__ . '/test2')); |
|
46 | + $tocifier = new Tocifier(file_get_contents(__DIR__.'/test2')); |
|
47 | 47 | $this->assertEquals($tocifier->getHtml(), ''); |
48 | 48 | $this->assertTrue($tocifier->process()); |
49 | 49 | |
50 | 50 | // Check the augmented HTML is equal to the original one |
51 | - $this->assertStringEqualsFile(__DIR__ . '/test2', $tocifier->getHtml()); |
|
51 | + $this->assertStringEqualsFile(__DIR__.'/test2', $tocifier->getHtml()); |
|
52 | 52 | |
53 | 53 | ob_start(); |
54 | 54 | $tocifier->dumpTOC(); |
@@ -8,8 +8,8 @@ |
||
8 | 8 | spl_autoload_register(function ($class) { |
9 | 9 | switch ($class) { |
10 | 10 | |
11 | - case 'Tocifier': |
|
12 | - require_once __DIR__ . '/../code/Tocifier.php'; |
|
13 | - break; |
|
11 | + case 'Tocifier': |
|
12 | + require_once __DIR__ . '/../code/Tocifier.php'; |
|
13 | + break; |
|
14 | 14 | } |
15 | 15 | }); |
@@ -5,11 +5,11 @@ |
||
5 | 5 | * phpunit --bootstrap tests/Bootstrap.php tests/ |
6 | 6 | */ |
7 | 7 | |
8 | -spl_autoload_register(function ($class) { |
|
8 | +spl_autoload_register(function($class) { |
|
9 | 9 | switch ($class) { |
10 | 10 | |
11 | 11 | case 'Tocifier': |
12 | - require_once __DIR__ . '/../code/Tocifier.php'; |
|
12 | + require_once __DIR__.'/../code/Tocifier.php'; |
|
13 | 13 | break; |
14 | 14 | } |
15 | 15 | }); |