Passed
Branch php-cs-fixer (b9836a)
by Fabio
15:58
created
framework/Collections/TPagedListIterator.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 		$this->_list = $list;
42 42
 		$this->_index = 0;
43 43
 		$this->_startIndex = $startIndex;
44
-		if($startIndex + $count > $list->getCount())
44
+		if ($startIndex + $count > $list->getCount())
45 45
 			$this->_count = $list->getCount() - $startIndex;
46 46
 		else
47 47
 			$this->_count = $count;
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,10 +41,11 @@
 block discarded – undo
41 41
 		$this->_list = $list;
42 42
 		$this->_index = 0;
43 43
 		$this->_startIndex = $startIndex;
44
-		if($startIndex + $count > $list->getCount())
45
-			$this->_count = $list->getCount() - $startIndex;
46
-		else
47
-			$this->_count = $count;
44
+		if($startIndex + $count > $list->getCount()) {
45
+					$this->_count = $list->getCount() - $startIndex;
46
+		} else {
47
+					$this->_count = $count;
48
+		}
48 49
 	}
49 50
 
50 51
 	/**
Please login to merge, or discard this patch.
framework/Collections/TPagedMapIterator.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		$this->_map = $map;
41 41
 		$this->_index = 0;
42 42
 		$this->_startIndex = $startIndex;
43
-		if($startIndex + $count > $map->getCount())
43
+		if ($startIndex + $count > $map->getCount())
44 44
 			$this->_count = $map->getCount() - $startIndex;
45 45
 		else
46 46
 			$this->_count = $count;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	public function rewind()
55 55
 	{
56 56
 		$this->_iterator->rewind();
57
-		for($i = 0;$i < $this->_startIndex;++$i)
57
+		for ($i = 0; $i < $this->_startIndex; ++$i)
58 58
 			$this->_iterator->next();
59 59
 		$this->_index = 0;
60 60
 	}
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,10 +40,11 @@  discard block
 block discarded – undo
40 40
 		$this->_map = $map;
41 41
 		$this->_index = 0;
42 42
 		$this->_startIndex = $startIndex;
43
-		if($startIndex + $count > $map->getCount())
44
-			$this->_count = $map->getCount() - $startIndex;
45
-		else
46
-			$this->_count = $count;
43
+		if($startIndex + $count > $map->getCount()) {
44
+					$this->_count = $map->getCount() - $startIndex;
45
+		} else {
46
+					$this->_count = $count;
47
+		}
47 48
 		$this->_iterator = $map->getIterator();
48 49
 	}
49 50
 
@@ -54,8 +55,9 @@  discard block
 block discarded – undo
54 55
 	public function rewind()
55 56
 	{
56 57
 		$this->_iterator->rewind();
57
-		for($i = 0;$i < $this->_startIndex;++$i)
58
-			$this->_iterator->next();
58
+		for($i = 0;$i < $this->_startIndex;++$i) {
59
+					$this->_iterator->next();
60
+		}
59 61
 		$this->_index = 0;
60 62
 	}
61 63
 
Please login to merge, or discard this patch.
framework/Collections/TMap.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function __construct($data = null, $readOnly = false)
74 74
 	{
75
-		if($data !== null)
75
+		if ($data !== null)
76 76
 			$this->copyFrom($data);
77 77
 		$this->setReadOnly($readOnly);
78 78
 	}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	public function add($key, $value)
151 151
 	{
152
-		if(!$this->_r)
152
+		if (!$this->_r)
153 153
 			$this->_d[$key] = $value;
154 154
 		else
155 155
 			throw new TInvalidOperationException('map_readonly', get_class($this));
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	public function remove($key)
165 165
 	{
166
-		if(!$this->_r)
166
+		if (!$this->_r)
167 167
 		{
168
-			if(isset($this->_d[$key]) || array_key_exists($key, $this->_d))
168
+			if (isset($this->_d[$key]) || array_key_exists($key, $this->_d))
169 169
 			{
170 170
 				$value = $this->_d[$key];
171 171
 				unset($this->_d[$key]);
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	public function clear()
185 185
 	{
186
-		foreach(array_keys($this->_d) as $key)
186
+		foreach (array_keys($this->_d) as $key)
187 187
 			$this->remove($key);
188 188
 	}
189 189
 
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function copyFrom($data)
214 214
 	{
215
-		if(is_array($data) || $data instanceof Traversable)
215
+		if (is_array($data) || $data instanceof Traversable)
216 216
 		{
217
-			if($this->getCount() > 0)
217
+			if ($this->getCount() > 0)
218 218
 				$this->clear();
219
-			foreach($data as $key => $value)
219
+			foreach ($data as $key => $value)
220 220
 				$this->add($key, $value);
221 221
 		}
222
-		elseif($data !== null)
222
+		elseif ($data !== null)
223 223
 			throw new TInvalidDataTypeException('map_data_not_iterable');
224 224
 	}
225 225
 
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 	 */
232 232
 	public function mergeWith($data)
233 233
 	{
234
-		if(is_array($data) || $data instanceof Traversable)
234
+		if (is_array($data) || $data instanceof Traversable)
235 235
 		{
236
-			foreach($data as $key => $value)
236
+			foreach ($data as $key => $value)
237 237
 				$this->add($key, $value);
238 238
 		}
239
-		elseif($data !== null)
239
+		elseif ($data !== null)
240 240
 			throw new TInvalidDataTypeException('map_data_not_iterable');
241 241
 	}
242 242
 
Please login to merge, or discard this patch.
Braces   +34 added lines, -26 removed lines patch added patch discarded remove patch
@@ -57,10 +57,12 @@  discard block
 block discarded – undo
57 57
 	protected function _getZappableSleepProps(&$exprops)
58 58
 	{
59 59
 		parent::_getZappableSleepProps($exprops);
60
-		if ($this->_d === [])
61
-			$exprops[] = "\0Prado\Collections\TMap\0_d";
62
-		if ($this->_r === false)
63
-			$exprops[] = "\0Prado\Collections\TMap\0_r";
60
+		if ($this->_d === []) {
61
+					$exprops[] = "\0Prado\Collections\TMap\0_d";
62
+		}
63
+		if ($this->_r === false) {
64
+					$exprops[] = "\0Prado\Collections\TMap\0_r";
65
+		}
64 66
 	}
65 67
 
66 68
 	/**
@@ -72,8 +74,9 @@  discard block
 block discarded – undo
72 74
 	 */
73 75
 	public function __construct($data = null, $readOnly = false)
74 76
 	{
75
-		if($data !== null)
76
-			$this->copyFrom($data);
77
+		if($data !== null) {
78
+					$this->copyFrom($data);
79
+		}
77 80
 		$this->setReadOnly($readOnly);
78 81
 	}
79 82
 
@@ -149,10 +152,11 @@  discard block
 block discarded – undo
149 152
 	 */
150 153
 	public function add($key, $value)
151 154
 	{
152
-		if(!$this->_r)
153
-			$this->_d[$key] = $value;
154
-		else
155
-			throw new TInvalidOperationException('map_readonly', get_class($this));
155
+		if(!$this->_r) {
156
+					$this->_d[$key] = $value;
157
+		} else {
158
+					throw new TInvalidOperationException('map_readonly', get_class($this));
159
+		}
156 160
 	}
157 161
 
158 162
 	/**
@@ -170,12 +174,12 @@  discard block
 block discarded – undo
170 174
 				$value = $this->_d[$key];
171 175
 				unset($this->_d[$key]);
172 176
 				return $value;
177
+			} else {
178
+							return null;
173 179
 			}
174
-			else
175
-				return null;
180
+		} else {
181
+					throw new TInvalidOperationException('map_readonly', get_class($this));
176 182
 		}
177
-		else
178
-			throw new TInvalidOperationException('map_readonly', get_class($this));
179 183
 	}
180 184
 
181 185
 	/**
@@ -183,8 +187,9 @@  discard block
 block discarded – undo
183 187
 	 */
184 188
 	public function clear()
185 189
 	{
186
-		foreach(array_keys($this->_d) as $key)
187
-			$this->remove($key);
190
+		foreach(array_keys($this->_d) as $key) {
191
+					$this->remove($key);
192
+		}
188 193
 	}
189 194
 
190 195
 	/**
@@ -214,13 +219,15 @@  discard block
 block discarded – undo
214 219
 	{
215 220
 		if(is_array($data) || $data instanceof Traversable)
216 221
 		{
217
-			if($this->getCount() > 0)
218
-				$this->clear();
219
-			foreach($data as $key => $value)
220
-				$this->add($key, $value);
222
+			if($this->getCount() > 0) {
223
+							$this->clear();
224
+			}
225
+			foreach($data as $key => $value) {
226
+							$this->add($key, $value);
227
+			}
228
+		} elseif($data !== null) {
229
+					throw new TInvalidDataTypeException('map_data_not_iterable');
221 230
 		}
222
-		elseif($data !== null)
223
-			throw new TInvalidDataTypeException('map_data_not_iterable');
224 231
 	}
225 232
 
226 233
 	/**
@@ -233,11 +240,12 @@  discard block
 block discarded – undo
233 240
 	{
234 241
 		if(is_array($data) || $data instanceof Traversable)
235 242
 		{
236
-			foreach($data as $key => $value)
237
-				$this->add($key, $value);
243
+			foreach($data as $key => $value) {
244
+							$this->add($key, $value);
245
+			}
246
+		} elseif($data !== null) {
247
+					throw new TInvalidDataTypeException('map_data_not_iterable');
238 248
 		}
239
-		elseif($data !== null)
240
-			throw new TInvalidDataTypeException('map_data_not_iterable');
241 249
 	}
242 250
 
243 251
 	/**
Please login to merge, or discard this patch.
framework/Collections/TListItemCollection.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	public function createListItem($index = -1)
39 39
 	{
40 40
 		$item = $this->createNewListItem();
41
-		if($index < 0)
41
+		if ($index < 0)
42 42
 			$this->add($item);
43 43
 		else
44 44
 			$this->insertAt($index, $item);
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	protected function createNewListItem($text = null)
52 52
 	{
53 53
 		$item = new TListItem;
54
-		if($text !== null)
54
+		if ($text !== null)
55 55
 			$item->setText($text);
56 56
 		return $item;
57 57
 	}
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function insertAt($index, $item)
67 67
 	{
68
-		if(is_string($item))
68
+		if (is_string($item))
69 69
 			$item = $this->createNewListItem($item);
70
-		if(!($item instanceof TListItem))
70
+		if (!($item instanceof TListItem))
71 71
 			throw new TInvalidDataTypeException('listitemcollection_item_invalid', get_class($this));
72 72
 		parent::insertAt($index, $item);
73 73
 	}
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 	{
83 83
 		$value = TPropertyValue::ensureString($value);
84 84
 		$index = 0;
85
-		foreach($this as $item)
85
+		foreach ($this as $item)
86 86
 		{
87
-			if($item->getValue() === $value && ($includeDisabled || $item->getEnabled()))
87
+			if ($item->getValue() === $value && ($includeDisabled || $item->getEnabled()))
88 88
 				return $index;
89 89
 			$index++;
90 90
 		}
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	{
102 102
 		$text = TPropertyValue::ensureString($text);
103 103
 		$index = 0;
104
-		foreach($this as $item)
104
+		foreach ($this as $item)
105 105
 		{
106
-			if($item->getText() === $text && ($includeDisabled || $item->getEnabled()))
106
+			if ($item->getText() === $text && ($includeDisabled || $item->getEnabled()))
107 107
 				return $index;
108 108
 			$index++;
109 109
 		}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function findItemByValue($value, $includeDisabled = true)
120 120
 	{
121
-		if(($index = $this->findIndexByValue($value, $includeDisabled)) >= 0)
121
+		if (($index = $this->findIndexByValue($value, $includeDisabled)) >= 0)
122 122
 			return $this->itemAt($index);
123 123
 		else
124 124
 			return null;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	public function findItemByText($text, $includeDisabled = true)
134 134
 	{
135
-		if(($index = $this->findIndexByText($text, $includeDisabled)) >= 0)
135
+		if (($index = $this->findIndexByText($text, $includeDisabled)) >= 0)
136 136
 			return $this->itemAt($index);
137 137
 		else
138 138
 			return null;
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	public function loadState($state)
147 147
 	{
148 148
 		$this->clear();
149
-		if($state !== null)
149
+		if ($state !== null)
150 150
 			$this->copyFrom($state);
151 151
 	}
152 152
 
Please login to merge, or discard this patch.
Braces   +33 added lines, -24 removed lines patch added patch discarded remove patch
@@ -38,10 +38,11 @@  discard block
 block discarded – undo
38 38
 	public function createListItem($index = -1)
39 39
 	{
40 40
 		$item = $this->createNewListItem();
41
-		if($index < 0)
42
-			$this->add($item);
43
-		else
44
-			$this->insertAt($index, $item);
41
+		if($index < 0) {
42
+					$this->add($item);
43
+		} else {
44
+					$this->insertAt($index, $item);
45
+		}
45 46
 		return $item;
46 47
 	}
47 48
 
@@ -51,8 +52,9 @@  discard block
 block discarded – undo
51 52
 	protected function createNewListItem($text = null)
52 53
 	{
53 54
 		$item = new TListItem;
54
-		if($text !== null)
55
-			$item->setText($text);
55
+		if($text !== null) {
56
+					$item->setText($text);
57
+		}
56 58
 		return $item;
57 59
 	}
58 60
 
@@ -65,10 +67,12 @@  discard block
 block discarded – undo
65 67
 	 */
66 68
 	public function insertAt($index, $item)
67 69
 	{
68
-		if(is_string($item))
69
-			$item = $this->createNewListItem($item);
70
-		if(!($item instanceof TListItem))
71
-			throw new TInvalidDataTypeException('listitemcollection_item_invalid', get_class($this));
70
+		if(is_string($item)) {
71
+					$item = $this->createNewListItem($item);
72
+		}
73
+		if(!($item instanceof TListItem)) {
74
+					throw new TInvalidDataTypeException('listitemcollection_item_invalid', get_class($this));
75
+		}
72 76
 		parent::insertAt($index, $item);
73 77
 	}
74 78
 
@@ -84,8 +88,9 @@  discard block
 block discarded – undo
84 88
 		$index = 0;
85 89
 		foreach($this as $item)
86 90
 		{
87
-			if($item->getValue() === $value && ($includeDisabled || $item->getEnabled()))
88
-				return $index;
91
+			if($item->getValue() === $value && ($includeDisabled || $item->getEnabled())) {
92
+							return $index;
93
+			}
89 94
 			$index++;
90 95
 		}
91 96
 		return -1;
@@ -103,8 +108,9 @@  discard block
 block discarded – undo
103 108
 		$index = 0;
104 109
 		foreach($this as $item)
105 110
 		{
106
-			if($item->getText() === $text && ($includeDisabled || $item->getEnabled()))
107
-				return $index;
111
+			if($item->getText() === $text && ($includeDisabled || $item->getEnabled())) {
112
+							return $index;
113
+			}
108 114
 			$index++;
109 115
 		}
110 116
 		return -1;
@@ -118,10 +124,11 @@  discard block
 block discarded – undo
118 124
 	 */
119 125
 	public function findItemByValue($value, $includeDisabled = true)
120 126
 	{
121
-		if(($index = $this->findIndexByValue($value, $includeDisabled)) >= 0)
122
-			return $this->itemAt($index);
123
-		else
124
-			return null;
127
+		if(($index = $this->findIndexByValue($value, $includeDisabled)) >= 0) {
128
+					return $this->itemAt($index);
129
+		} else {
130
+					return null;
131
+		}
125 132
 	}
126 133
 
127 134
 	/**
@@ -132,10 +139,11 @@  discard block
 block discarded – undo
132 139
 	 */
133 140
 	public function findItemByText($text, $includeDisabled = true)
134 141
 	{
135
-		if(($index = $this->findIndexByText($text, $includeDisabled)) >= 0)
136
-			return $this->itemAt($index);
137
-		else
138
-			return null;
142
+		if(($index = $this->findIndexByText($text, $includeDisabled)) >= 0) {
143
+					return $this->itemAt($index);
144
+		} else {
145
+					return null;
146
+		}
139 147
 	}
140 148
 
141 149
 	/**
@@ -146,8 +154,9 @@  discard block
 block discarded – undo
146 154
 	public function loadState($state)
147 155
 	{
148 156
 		$this->clear();
149
-		if($state !== null)
150
-			$this->copyFrom($state);
157
+		if($state !== null) {
158
+					$this->copyFrom($state);
159
+		}
151 160
 	}
152 161
 
153 162
 	/**
Please login to merge, or discard this patch.
framework/Collections/TPriorityList.php 2 patches
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	public function __construct($data = null, $readOnly = false, $defaultPriority = 10, $precision = 8)
92 92
 	{
93 93
 		parent::__construct();
94
-		if($data !== null)
94
+		if ($data !== null)
95 95
 			$this->copyFrom($data);
96 96
 		$this->setReadOnly($readOnly);
97 97
 		$this->setPrecision($precision);
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 	 */
125 125
 	public function getPriorityCount($priority = null)
126 126
 	{
127
-		if($priority === null)
127
+		if ($priority === null)
128 128
 			$priority = $this->getDefaultPriority();
129
-		$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
129
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
130 130
 
131
-		if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority]))
131
+		if (!isset($this->_d[$priority]) || !is_array($this->_d[$priority]))
132 132
 			return false;
133 133
 		return count($this->_d[$priority]);
134 134
 	}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	protected function setDefaultPriority($value)
149 149
 	{
150
-		$this->_dp = (string)round(TPropertyValue::ensureFloat($value), $this->_p);
150
+		$this->_dp = (string) round(TPropertyValue::ensureFloat($value), $this->_p);
151 151
 	}
152 152
 
153 153
 	/**
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * This orders the priority list internally.
193 193
 	 */
194 194
 	protected function sortPriorities() {
195
-		if(!$this->_o) {
195
+		if (!$this->_o) {
196 196
 			ksort($this->_d, SORT_NUMERIC);
197 197
 			$this->_o = true;
198 198
 		}
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
 	 * @return array array of items in the list in priority and index order
204 204
 	 */
205 205
 	protected function flattenPriorities() {
206
-		if(is_array($this->_fd))
206
+		if (is_array($this->_fd))
207 207
 			return $this->_fd;
208 208
 
209 209
 		$this->sortPriorities();
210 210
 		$this->_fd = [];
211
-		foreach($this->_d as $priority => $itemsatpriority)
211
+		foreach ($this->_d as $priority => $itemsatpriority)
212 212
 			$this->_fd = array_merge($this->_fd, $itemsatpriority);
213 213
 		return $this->_fd;
214 214
 	}
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 */
224 224
 	public function itemAt($index)
225 225
 	{
226
-		if($index >= 0 && $index < $this->getCount()) {
226
+		if ($index >= 0 && $index < $this->getCount()) {
227 227
 			$arr = $this->flattenPriorities();
228 228
 			return $arr[$index];
229 229
 		} else
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	public function itemsAtPriority($priority = null)
239 239
 	{
240
-		if($priority === null)
240
+		if ($priority === null)
241 241
 			$priority = $this->getDefaultPriority();
242
-		$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
242
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
243 243
 
244
-		return isset($this->_d[$priority])?$this->_d[$priority]:null;
244
+		return isset($this->_d[$priority]) ? $this->_d[$priority] : null;
245 245
 	}
246 246
 
247 247
 	/**
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
 	 */
253 253
 	public function itemAtIndexInPriority($index, $priority = null)
254 254
 	{
255
-		if($priority === null)
255
+		if ($priority === null)
256 256
 			$priority = $this->getDefaultPriority();
257
-		$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
257
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
258 258
 
259
-		return !isset($this->_d[$priority])?false:(
260
-				isset($this->_d[$priority][$index])?$this->_d[$priority][$index]:false
259
+		return !isset($this->_d[$priority]) ?false:(
260
+				isset($this->_d[$priority][$index]) ? $this->_d[$priority][$index] : false
261 261
 			);
262 262
 	}
263 263
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 */
272 272
 	public function add($item, $priority = null)
273 273
 	{
274
-		if($this->getReadOnly())
274
+		if ($this->getReadOnly())
275 275
 			throw new TInvalidOperationException('list_readonly', get_class($this));
276 276
 
277 277
 		return $this->insertAtIndexInPriority($item, false, $priority, true);
@@ -287,10 +287,10 @@  discard block
 block discarded – undo
287 287
 	 */
288 288
 	public function insertAt($index, $item)
289 289
 	{
290
-		if($this->getReadOnly())
290
+		if ($this->getReadOnly())
291 291
 			throw new TInvalidOperationException('list_readonly', get_class($this));
292 292
 
293
-		if(($priority = $this->priorityAt($index, true)) !== false)
293
+		if (($priority = $this->priorityAt($index, true)) !== false)
294 294
 			$this->insertAtIndexInPriority($item, $priority[1], $priority[0]);
295 295
 		else
296 296
 			throw new TInvalidDataValueException('list_index_invalid', $index);
@@ -308,27 +308,27 @@  discard block
 block discarded – undo
308 308
 	 */
309 309
 	public function insertAtIndexInPriority($item, $index = false, $priority = null, $preserveCache = false)
310 310
 	{
311
-		if($this->getReadOnly())
311
+		if ($this->getReadOnly())
312 312
 			throw new TInvalidOperationException('list_readonly', get_class($this));
313 313
 
314
-		if($priority === null)
314
+		if ($priority === null)
315 315
 			$priority = $this->getDefaultPriority();
316
-		$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
316
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
317 317
 
318
-		if($preserveCache) {
318
+		if ($preserveCache) {
319 319
 			$this->sortPriorities();
320 320
 			$cc = 0;
321
-			foreach($this->_d as $prioritykey => $items)
322
-				if($prioritykey >= $priority)
321
+			foreach ($this->_d as $prioritykey => $items)
322
+				if ($prioritykey >= $priority)
323 323
 					break;
324 324
 				else
325 325
 					$cc += count($items);
326 326
 
327
-			if($index === false && isset($this->_d[$priority])) {
327
+			if ($index === false && isset($this->_d[$priority])) {
328 328
 				$c = count($this->_d[$priority]);
329 329
 				$c += $cc;
330 330
 				$this->_d[$priority][] = $item;
331
-			} elseif(isset($this->_d[$priority])) {
331
+			} elseif (isset($this->_d[$priority])) {
332 332
 				$c = $index + $cc;
333 333
 				array_splice($this->_d[$priority], $index, 0, [$item]);
334 334
 			} else {
@@ -337,14 +337,14 @@  discard block
 block discarded – undo
337 337
 				$this->_d[$priority] = [$item];
338 338
 			}
339 339
 
340
-			if($this->_fd && is_array($this->_fd)) // if there is a flattened array cache
340
+			if ($this->_fd && is_array($this->_fd)) // if there is a flattened array cache
341 341
 				array_splice($this->_fd, $c, 0, [$item]);
342 342
 		} else {
343 343
 			$c = null;
344
-			if($index === false && isset($this->_d[$priority])) {
344
+			if ($index === false && isset($this->_d[$priority])) {
345 345
 				$cc = count($this->_d[$priority]);
346 346
 				$this->_d[$priority][] = $item;
347
-			} elseif(isset($this->_d[$priority])) {
347
+			} elseif (isset($this->_d[$priority])) {
348 348
 				$cc = $index;
349 349
 				array_splice($this->_d[$priority], $index, 0, [$item]);
350 350
 			} else {
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				$this->_o = false;
353 353
 				$this->_d[$priority] = [$item];
354 354
 			}
355
-			if($this->_fd && is_array($this->_fd) && count($this->_d) == 1)
355
+			if ($this->_fd && is_array($this->_fd) && count($this->_d) == 1)
356 356
 				array_splice($this->_fd, $cc, 0, [$item]);
357 357
 			else
358 358
 				$this->_fd = null;
@@ -376,17 +376,17 @@  discard block
 block discarded – undo
376 376
 	 */
377 377
 	public function remove($item, $priority = false)
378 378
 	{
379
-		if($this->getReadOnly())
379
+		if ($this->getReadOnly())
380 380
 			throw new TInvalidOperationException('list_readonly', get_class($this));
381 381
 
382
-		if(($p = $this->priorityOf($item, true)) !== false)
382
+		if (($p = $this->priorityOf($item, true)) !== false)
383 383
 		{
384
-			if($priority !== false) {
385
-				if($priority === null)
384
+			if ($priority !== false) {
385
+				if ($priority === null)
386 386
 					$priority = $this->getDefaultPriority();
387
-				$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
387
+				$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
388 388
 
389
-				if($p[0] != $priority)
389
+				if ($p[0] != $priority)
390 390
 					throw new TInvalidDataValueException('list_item_inexistent');
391 391
 			}
392 392
 			$this->removeAtIndexInPriority($p[1], $p[0]);
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
 	 */
406 406
 	public function removeAt($index)
407 407
 	{
408
-		if($this->getReadOnly())
408
+		if ($this->getReadOnly())
409 409
 			throw new TInvalidOperationException('list_readonly', get_class($this));
410 410
 
411
-		if(($priority = $this->priorityAt($index, true)) !== false)
411
+		if (($priority = $this->priorityAt($index, true)) !== false)
412 412
 			return $this->removeAtIndexInPriority($priority[1], $priority[0]);
413 413
 		throw new TInvalidDataValueException('list_index_invalid', $index);
414 414
 	}
@@ -423,21 +423,21 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	public function removeAtIndexInPriority($index, $priority = null)
425 425
 	{
426
-		if($this->getReadOnly())
426
+		if ($this->getReadOnly())
427 427
 			throw new TInvalidOperationException('list_readonly', get_class($this));
428 428
 
429
-		if($priority === null)
429
+		if ($priority === null)
430 430
 			$priority = $this->getDefaultPriority();
431
-		$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
431
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
432 432
 
433
-		if(!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority]))
433
+		if (!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority]))
434 434
 			throw new TInvalidDataValueException('list_item_inexistent');
435 435
 
436 436
 		// $value is an array of elements removed, only one
437 437
 		$value = array_splice($this->_d[$priority], $index, 1);
438 438
 		$value = $value[0];
439 439
 
440
-		if(!count($this->_d[$priority]))
440
+		if (!count($this->_d[$priority]))
441 441
 			unset($this->_d[$priority]);
442 442
 
443 443
 		$this->_c--;
@@ -450,11 +450,11 @@  discard block
 block discarded – undo
450 450
 	 */
451 451
 	public function clear()
452 452
 	{
453
-		if($this->getReadOnly())
453
+		if ($this->getReadOnly())
454 454
 			throw new TInvalidOperationException('list_readonly', get_class($this));
455 455
 
456
-		foreach($this->_d as $priority => $items) {
457
-			for($index = count($items) - 1;$index >= 0;$index--)
456
+		foreach ($this->_d as $priority => $items) {
457
+			for ($index = count($items) - 1; $index >= 0; $index--)
458 458
 				$this->removeAtIndexInPriority($index, $priority);
459 459
 			unset($this->_d[$priority]);
460 460
 		}
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 	 */
476 476
 	public function indexOf($item)
477 477
 	{
478
-		if(($index = array_search($item, $this->flattenPriorities(), true)) === false)
478
+		if (($index = array_search($item, $this->flattenPriorities(), true)) === false)
479 479
 			return -1;
480 480
 		else
481 481
 			return $index;
@@ -495,11 +495,11 @@  discard block
 block discarded – undo
495 495
 		$this->sortPriorities();
496 496
 
497 497
 		$absindex = 0;
498
-		foreach($this->_d as $priority => $items) {
499
-			if(($index = array_search($item, $items, true)) !== false) {
498
+		foreach ($this->_d as $priority => $items) {
499
+			if (($index = array_search($item, $items, true)) !== false) {
500 500
 				$absindex += $index;
501
-				return $withindex?[$priority,$index,$absindex,
502
-						'priority' => $priority,'index' => $index,'absindex' => $absindex]:$priority;
501
+				return $withindex ? [$priority, $index, $absindex,
502
+						'priority' => $priority, 'index' => $index, 'absindex' => $absindex] : $priority;
503 503
 			} else
504 504
 				$absindex += count($items);
505 505
 		}
@@ -518,17 +518,17 @@  discard block
 block discarded – undo
518 518
 	 */
519 519
 	public function priorityAt($index, $withindex = false)
520 520
 	{
521
-		if($index < 0 || $index >= $this->getCount())
521
+		if ($index < 0 || $index >= $this->getCount())
522 522
 			throw new TInvalidDataValueException('list_index_invalid', $index);
523 523
 
524 524
 		$absindex = $index;
525 525
 		$this->sortPriorities();
526
-		foreach($this->_d as $priority => $items) {
527
-			if($index >= ($c = count($items)))
526
+		foreach ($this->_d as $priority => $items) {
527
+			if ($index >= ($c = count($items)))
528 528
 				$index -= $c;
529 529
 			else
530
-				return $withindex?[$priority,$index,$absindex,
531
-						'priority' => $priority,'index' => $index,'absindex' => $absindex]:$priority;
530
+				return $withindex ? [$priority, $index, $absindex,
531
+						'priority' => $priority, 'index' => $index, 'absindex' => $absindex] : $priority;
532 532
 		}
533 533
 		return false;
534 534
 	}
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
 	 */
544 544
 	public function insertBefore($indexitem, $item)
545 545
 	{
546
-		if($this->getReadOnly())
546
+		if ($this->getReadOnly())
547 547
 			throw new TInvalidOperationException('list_readonly', get_class($this));
548 548
 
549
-		if(($priority = $this->priorityOf($indexitem, true)) === false)
549
+		if (($priority = $this->priorityOf($indexitem, true)) === false)
550 550
 			throw new TInvalidDataValueException('list_item_inexistent');
551 551
 
552 552
 		$this->insertAtIndexInPriority($item, $priority[1], $priority[0]);
@@ -564,10 +564,10 @@  discard block
 block discarded – undo
564 564
 	 */
565 565
 	public function insertAfter($indexitem, $item)
566 566
 	{
567
-		if($this->getReadOnly())
567
+		if ($this->getReadOnly())
568 568
 			throw new TInvalidOperationException('list_readonly', get_class($this));
569 569
 
570
-		if(($priority = $this->priorityOf($indexitem, true)) === false)
570
+		if (($priority = $this->priorityOf($indexitem, true)) === false)
571 571
 			throw new TInvalidDataValueException('list_item_inexistent');
572 572
 
573 573
 		$this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]);
@@ -603,9 +603,9 @@  discard block
 block discarded – undo
603 603
 	{
604 604
 		$this->sortPriorities();
605 605
 		$items = [];
606
-		foreach($this->_d as $itemspriority => $itemsatpriority)
606
+		foreach ($this->_d as $itemspriority => $itemsatpriority)
607 607
 		{
608
-			if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority)
608
+			if ((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority)
609 609
 				break;
610 610
 			$items = array_merge($items, $itemsatpriority);
611 611
 		}
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
 	{
624 624
 		$this->sortPriorities();
625 625
 		$items = [];
626
-		foreach($this->_d as $itemspriority => $itemsatpriority)
626
+		foreach ($this->_d as $itemspriority => $itemsatpriority)
627 627
 		{
628
-			if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority)
628
+			if ((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority)
629 629
 				continue;
630 630
 			$items = array_merge($items, $itemsatpriority);
631 631
 		}
@@ -641,21 +641,21 @@  discard block
 block discarded – undo
641 641
 	 */
642 642
 	public function copyFrom($data)
643 643
 	{
644
-		if($data instanceof TPriorityList)
644
+		if ($data instanceof TPriorityList)
645 645
 		{
646
-			if($this->getCount() > 0)
646
+			if ($this->getCount() > 0)
647 647
 				$this->clear();
648
-			foreach($data->getPriorities() as $priority)
648
+			foreach ($data->getPriorities() as $priority)
649 649
 			{
650
-				foreach($data->itemsAtPriority($priority) as $index => $item)
650
+				foreach ($data->itemsAtPriority($priority) as $index => $item)
651 651
 					$this->insertAtIndexInPriority($item, $index, $priority);
652 652
 			}
653
-		} elseif(is_array($data) || $data instanceof \Traversable) {
654
-			if($this->getCount() > 0)
653
+		} elseif (is_array($data) || $data instanceof \Traversable) {
654
+			if ($this->getCount() > 0)
655 655
 				$this->clear();
656
-			foreach($data as $key => $item)
656
+			foreach ($data as $key => $item)
657 657
 				$this->add($item);
658
-		} elseif($data !== null)
658
+		} elseif ($data !== null)
659 659
 			throw new TInvalidDataTypeException('map_data_not_iterable');
660 660
 	}
661 661
 
@@ -669,21 +669,21 @@  discard block
 block discarded – undo
669 669
 	 */
670 670
 	public function mergeWith($data)
671 671
 	{
672
-		if($data instanceof TPriorityList)
672
+		if ($data instanceof TPriorityList)
673 673
 		{
674
-			foreach($data->getPriorities() as $priority)
674
+			foreach ($data->getPriorities() as $priority)
675 675
 			{
676
-				foreach($data->itemsAtPriority($priority) as $index => $item)
676
+				foreach ($data->itemsAtPriority($priority) as $index => $item)
677 677
 					$this->insertAtIndexInPriority($item, false, $priority);
678 678
 			}
679 679
 		}
680
-		elseif(is_array($data) || $data instanceof \Traversable)
680
+		elseif (is_array($data) || $data instanceof \Traversable)
681 681
 		{
682
-			foreach($data as $priority => $item)
682
+			foreach ($data as $priority => $item)
683 683
 				$this->add($item);
684 684
 
685 685
 		}
686
-		elseif($data !== null)
686
+		elseif ($data !== null)
687 687
 			throw new TInvalidDataTypeException('map_data_not_iterable');
688 688
 	}
689 689
 
@@ -723,9 +723,9 @@  discard block
 block discarded – undo
723 723
 	 */
724 724
 	public function offsetSet($offset, $item)
725 725
 	{
726
-		if($offset === null)
726
+		if ($offset === null)
727 727
 			return $this->add($item);
728
-		if($offset === $this->getCount()) {
728
+		if ($offset === $this->getCount()) {
729 729
 			$priority = $this->priorityAt($offset - 1, true);
730 730
 			$priority[1]++;
731 731
 		} else {
Please login to merge, or discard this patch.
Braces   +151 added lines, -105 removed lines patch added patch discarded remove patch
@@ -91,8 +91,9 @@  discard block
 block discarded – undo
91 91
 	public function __construct($data = null, $readOnly = false, $defaultPriority = 10, $precision = 8)
92 92
 	{
93 93
 		parent::__construct();
94
-		if($data !== null)
95
-			$this->copyFrom($data);
94
+		if($data !== null) {
95
+					$this->copyFrom($data);
96
+		}
96 97
 		$this->setReadOnly($readOnly);
97 98
 		$this->setPrecision($precision);
98 99
 		$this->setDefaultPriority($defaultPriority);
@@ -124,12 +125,14 @@  discard block
 block discarded – undo
124 125
 	 */
125 126
 	public function getPriorityCount($priority = null)
126 127
 	{
127
-		if($priority === null)
128
-			$priority = $this->getDefaultPriority();
128
+		if($priority === null) {
129
+					$priority = $this->getDefaultPriority();
130
+		}
129 131
 		$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
130 132
 
131
-		if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority]))
132
-			return false;
133
+		if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) {
134
+					return false;
135
+		}
133 136
 		return count($this->_d[$priority]);
134 137
 	}
135 138
 
@@ -203,13 +206,15 @@  discard block
 block discarded – undo
203 206
 	 * @return array array of items in the list in priority and index order
204 207
 	 */
205 208
 	protected function flattenPriorities() {
206
-		if(is_array($this->_fd))
207
-			return $this->_fd;
209
+		if(is_array($this->_fd)) {
210
+					return $this->_fd;
211
+		}
208 212
 
209 213
 		$this->sortPriorities();
210 214
 		$this->_fd = [];
211
-		foreach($this->_d as $priority => $itemsatpriority)
212
-			$this->_fd = array_merge($this->_fd, $itemsatpriority);
215
+		foreach($this->_d as $priority => $itemsatpriority) {
216
+					$this->_fd = array_merge($this->_fd, $itemsatpriority);
217
+		}
213 218
 		return $this->_fd;
214 219
 	}
215 220
 
@@ -226,8 +231,9 @@  discard block
 block discarded – undo
226 231
 		if($index >= 0 && $index < $this->getCount()) {
227 232
 			$arr = $this->flattenPriorities();
228 233
 			return $arr[$index];
229
-		} else
230
-			throw new TInvalidDataValueException('list_index_invalid', $index);
234
+		} else {
235
+					throw new TInvalidDataValueException('list_index_invalid', $index);
236
+		}
231 237
 	}
232 238
 
233 239
 	/**
@@ -237,8 +243,9 @@  discard block
 block discarded – undo
237 243
 	 */
238 244
 	public function itemsAtPriority($priority = null)
239 245
 	{
240
-		if($priority === null)
241
-			$priority = $this->getDefaultPriority();
246
+		if($priority === null) {
247
+					$priority = $this->getDefaultPriority();
248
+		}
242 249
 		$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
243 250
 
244 251
 		return isset($this->_d[$priority])?$this->_d[$priority]:null;
@@ -252,8 +259,9 @@  discard block
 block discarded – undo
252 259
 	 */
253 260
 	public function itemAtIndexInPriority($index, $priority = null)
254 261
 	{
255
-		if($priority === null)
256
-			$priority = $this->getDefaultPriority();
262
+		if($priority === null) {
263
+					$priority = $this->getDefaultPriority();
264
+		}
257 265
 		$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
258 266
 
259 267
 		return !isset($this->_d[$priority])?false:(
@@ -271,8 +279,9 @@  discard block
 block discarded – undo
271 279
 	 */
272 280
 	public function add($item, $priority = null)
273 281
 	{
274
-		if($this->getReadOnly())
275
-			throw new TInvalidOperationException('list_readonly', get_class($this));
282
+		if($this->getReadOnly()) {
283
+					throw new TInvalidOperationException('list_readonly', get_class($this));
284
+		}
276 285
 
277 286
 		return $this->insertAtIndexInPriority($item, false, $priority, true);
278 287
 	}
@@ -287,13 +296,15 @@  discard block
 block discarded – undo
287 296
 	 */
288 297
 	public function insertAt($index, $item)
289 298
 	{
290
-		if($this->getReadOnly())
291
-			throw new TInvalidOperationException('list_readonly', get_class($this));
299
+		if($this->getReadOnly()) {
300
+					throw new TInvalidOperationException('list_readonly', get_class($this));
301
+		}
292 302
 
293
-		if(($priority = $this->priorityAt($index, true)) !== false)
294
-			$this->insertAtIndexInPriority($item, $priority[1], $priority[0]);
295
-		else
296
-			throw new TInvalidDataValueException('list_index_invalid', $index);
303
+		if(($priority = $this->priorityAt($index, true)) !== false) {
304
+					$this->insertAtIndexInPriority($item, $priority[1], $priority[0]);
305
+		} else {
306
+					throw new TInvalidDataValueException('list_index_invalid', $index);
307
+		}
297 308
 	}
298 309
 
299 310
 	/**
@@ -308,21 +319,25 @@  discard block
 block discarded – undo
308 319
 	 */
309 320
 	public function insertAtIndexInPriority($item, $index = false, $priority = null, $preserveCache = false)
310 321
 	{
311
-		if($this->getReadOnly())
312
-			throw new TInvalidOperationException('list_readonly', get_class($this));
322
+		if($this->getReadOnly()) {
323
+					throw new TInvalidOperationException('list_readonly', get_class($this));
324
+		}
313 325
 
314
-		if($priority === null)
315
-			$priority = $this->getDefaultPriority();
326
+		if($priority === null) {
327
+					$priority = $this->getDefaultPriority();
328
+		}
316 329
 		$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
317 330
 
318 331
 		if($preserveCache) {
319 332
 			$this->sortPriorities();
320 333
 			$cc = 0;
321
-			foreach($this->_d as $prioritykey => $items)
322
-				if($prioritykey >= $priority)
334
+			foreach($this->_d as $prioritykey => $items) {
335
+							if($prioritykey >= $priority)
323 336
 					break;
324
-				else
325
-					$cc += count($items);
337
+			}
338
+				else {
339
+									$cc += count($items);
340
+				}
326 341
 
327 342
 			if($index === false && isset($this->_d[$priority])) {
328 343
 				$c = count($this->_d[$priority]);
@@ -337,8 +352,10 @@  discard block
 block discarded – undo
337 352
 				$this->_d[$priority] = [$item];
338 353
 			}
339 354
 
340
-			if($this->_fd && is_array($this->_fd)) // if there is a flattened array cache
355
+			if($this->_fd && is_array($this->_fd)) {
356
+				// if there is a flattened array cache
341 357
 				array_splice($this->_fd, $c, 0, [$item]);
358
+			}
342 359
 		} else {
343 360
 			$c = null;
344 361
 			if($index === false && isset($this->_d[$priority])) {
@@ -352,10 +369,11 @@  discard block
 block discarded – undo
352 369
 				$this->_o = false;
353 370
 				$this->_d[$priority] = [$item];
354 371
 			}
355
-			if($this->_fd && is_array($this->_fd) && count($this->_d) == 1)
356
-				array_splice($this->_fd, $cc, 0, [$item]);
357
-			else
358
-				$this->_fd = null;
372
+			if($this->_fd && is_array($this->_fd) && count($this->_d) == 1) {
373
+							array_splice($this->_fd, $cc, 0, [$item]);
374
+			} else {
375
+							$this->_fd = null;
376
+			}
359 377
 		}
360 378
 
361 379
 		$this->_c++;
@@ -376,24 +394,27 @@  discard block
 block discarded – undo
376 394
 	 */
377 395
 	public function remove($item, $priority = false)
378 396
 	{
379
-		if($this->getReadOnly())
380
-			throw new TInvalidOperationException('list_readonly', get_class($this));
397
+		if($this->getReadOnly()) {
398
+					throw new TInvalidOperationException('list_readonly', get_class($this));
399
+		}
381 400
 
382 401
 		if(($p = $this->priorityOf($item, true)) !== false)
383 402
 		{
384 403
 			if($priority !== false) {
385
-				if($priority === null)
386
-					$priority = $this->getDefaultPriority();
404
+				if($priority === null) {
405
+									$priority = $this->getDefaultPriority();
406
+				}
387 407
 				$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
388 408
 
389
-				if($p[0] != $priority)
390
-					throw new TInvalidDataValueException('list_item_inexistent');
409
+				if($p[0] != $priority) {
410
+									throw new TInvalidDataValueException('list_item_inexistent');
411
+				}
391 412
 			}
392 413
 			$this->removeAtIndexInPriority($p[1], $p[0]);
393 414
 			return $p[2];
415
+		} else {
416
+					throw new TInvalidDataValueException('list_item_inexistent');
394 417
 		}
395
-		else
396
-			throw new TInvalidDataValueException('list_item_inexistent');
397 418
 	}
398 419
 
399 420
 	/**
@@ -405,11 +426,13 @@  discard block
 block discarded – undo
405 426
 	 */
406 427
 	public function removeAt($index)
407 428
 	{
408
-		if($this->getReadOnly())
409
-			throw new TInvalidOperationException('list_readonly', get_class($this));
429
+		if($this->getReadOnly()) {
430
+					throw new TInvalidOperationException('list_readonly', get_class($this));
431
+		}
410 432
 
411
-		if(($priority = $this->priorityAt($index, true)) !== false)
412
-			return $this->removeAtIndexInPriority($priority[1], $priority[0]);
433
+		if(($priority = $this->priorityAt($index, true)) !== false) {
434
+					return $this->removeAtIndexInPriority($priority[1], $priority[0]);
435
+		}
413 436
 		throw new TInvalidDataValueException('list_index_invalid', $index);
414 437
 	}
415 438
 
@@ -423,22 +446,26 @@  discard block
 block discarded – undo
423 446
 	 */
424 447
 	public function removeAtIndexInPriority($index, $priority = null)
425 448
 	{
426
-		if($this->getReadOnly())
427
-			throw new TInvalidOperationException('list_readonly', get_class($this));
449
+		if($this->getReadOnly()) {
450
+					throw new TInvalidOperationException('list_readonly', get_class($this));
451
+		}
428 452
 
429
-		if($priority === null)
430
-			$priority = $this->getDefaultPriority();
453
+		if($priority === null) {
454
+					$priority = $this->getDefaultPriority();
455
+		}
431 456
 		$priority = (string)round(TPropertyValue::ensureFloat($priority), $this->_p);
432 457
 
433
-		if(!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority]))
434
-			throw new TInvalidDataValueException('list_item_inexistent');
458
+		if(!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority])) {
459
+					throw new TInvalidDataValueException('list_item_inexistent');
460
+		}
435 461
 
436 462
 		// $value is an array of elements removed, only one
437 463
 		$value = array_splice($this->_d[$priority], $index, 1);
438 464
 		$value = $value[0];
439 465
 
440
-		if(!count($this->_d[$priority]))
441
-			unset($this->_d[$priority]);
466
+		if(!count($this->_d[$priority])) {
467
+					unset($this->_d[$priority]);
468
+		}
442 469
 
443 470
 		$this->_c--;
444 471
 		$this->_fd = null;
@@ -450,12 +477,14 @@  discard block
 block discarded – undo
450 477
 	 */
451 478
 	public function clear()
452 479
 	{
453
-		if($this->getReadOnly())
454
-			throw new TInvalidOperationException('list_readonly', get_class($this));
480
+		if($this->getReadOnly()) {
481
+					throw new TInvalidOperationException('list_readonly', get_class($this));
482
+		}
455 483
 
456 484
 		foreach($this->_d as $priority => $items) {
457
-			for($index = count($items) - 1;$index >= 0;$index--)
458
-				$this->removeAtIndexInPriority($index, $priority);
485
+			for($index = count($items) - 1;$index >= 0;$index--) {
486
+							$this->removeAtIndexInPriority($index, $priority);
487
+			}
459 488
 			unset($this->_d[$priority]);
460 489
 		}
461 490
 	}
@@ -475,10 +504,11 @@  discard block
 block discarded – undo
475 504
 	 */
476 505
 	public function indexOf($item)
477 506
 	{
478
-		if(($index = array_search($item, $this->flattenPriorities(), true)) === false)
479
-			return -1;
480
-		else
481
-			return $index;
507
+		if(($index = array_search($item, $this->flattenPriorities(), true)) === false) {
508
+					return -1;
509
+		} else {
510
+					return $index;
511
+		}
482 512
 	}
483 513
 
484 514
 	/**
@@ -500,8 +530,9 @@  discard block
 block discarded – undo
500 530
 				$absindex += $index;
501 531
 				return $withindex?[$priority,$index,$absindex,
502 532
 						'priority' => $priority,'index' => $index,'absindex' => $absindex]:$priority;
503
-			} else
504
-				$absindex += count($items);
533
+			} else {
534
+							$absindex += count($items);
535
+			}
505 536
 		}
506 537
 
507 538
 		return false;
@@ -518,17 +549,19 @@  discard block
 block discarded – undo
518 549
 	 */
519 550
 	public function priorityAt($index, $withindex = false)
520 551
 	{
521
-		if($index < 0 || $index >= $this->getCount())
522
-			throw new TInvalidDataValueException('list_index_invalid', $index);
552
+		if($index < 0 || $index >= $this->getCount()) {
553
+					throw new TInvalidDataValueException('list_index_invalid', $index);
554
+		}
523 555
 
524 556
 		$absindex = $index;
525 557
 		$this->sortPriorities();
526 558
 		foreach($this->_d as $priority => $items) {
527
-			if($index >= ($c = count($items)))
528
-				$index -= $c;
529
-			else
530
-				return $withindex?[$priority,$index,$absindex,
559
+			if($index >= ($c = count($items))) {
560
+							$index -= $c;
561
+			} else {
562
+							return $withindex?[$priority,$index,$absindex,
531 563
 						'priority' => $priority,'index' => $index,'absindex' => $absindex]:$priority;
564
+			}
532 565
 		}
533 566
 		return false;
534 567
 	}
@@ -543,11 +576,13 @@  discard block
 block discarded – undo
543 576
 	 */
544 577
 	public function insertBefore($indexitem, $item)
545 578
 	{
546
-		if($this->getReadOnly())
547
-			throw new TInvalidOperationException('list_readonly', get_class($this));
579
+		if($this->getReadOnly()) {
580
+					throw new TInvalidOperationException('list_readonly', get_class($this));
581
+		}
548 582
 
549
-		if(($priority = $this->priorityOf($indexitem, true)) === false)
550
-			throw new TInvalidDataValueException('list_item_inexistent');
583
+		if(($priority = $this->priorityOf($indexitem, true)) === false) {
584
+					throw new TInvalidDataValueException('list_item_inexistent');
585
+		}
551 586
 
552 587
 		$this->insertAtIndexInPriority($item, $priority[1], $priority[0]);
553 588
 
@@ -564,11 +599,13 @@  discard block
 block discarded – undo
564 599
 	 */
565 600
 	public function insertAfter($indexitem, $item)
566 601
 	{
567
-		if($this->getReadOnly())
568
-			throw new TInvalidOperationException('list_readonly', get_class($this));
602
+		if($this->getReadOnly()) {
603
+					throw new TInvalidOperationException('list_readonly', get_class($this));
604
+		}
569 605
 
570
-		if(($priority = $this->priorityOf($indexitem, true)) === false)
571
-			throw new TInvalidDataValueException('list_item_inexistent');
606
+		if(($priority = $this->priorityOf($indexitem, true)) === false) {
607
+					throw new TInvalidDataValueException('list_item_inexistent');
608
+		}
572 609
 
573 610
 		$this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]);
574 611
 
@@ -605,8 +642,9 @@  discard block
 block discarded – undo
605 642
 		$items = [];
606 643
 		foreach($this->_d as $itemspriority => $itemsatpriority)
607 644
 		{
608
-			if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority)
609
-				break;
645
+			if((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority) {
646
+							break;
647
+			}
610 648
 			$items = array_merge($items, $itemsatpriority);
611 649
 		}
612 650
 		return $items;
@@ -625,8 +663,9 @@  discard block
 block discarded – undo
625 663
 		$items = [];
626 664
 		foreach($this->_d as $itemspriority => $itemsatpriority)
627 665
 		{
628
-			if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority)
629
-				continue;
666
+			if((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority) {
667
+							continue;
668
+			}
630 669
 			$items = array_merge($items, $itemsatpriority);
631 670
 		}
632 671
 		return $items;
@@ -643,20 +682,25 @@  discard block
 block discarded – undo
643 682
 	{
644 683
 		if($data instanceof TPriorityList)
645 684
 		{
646
-			if($this->getCount() > 0)
647
-				$this->clear();
685
+			if($this->getCount() > 0) {
686
+							$this->clear();
687
+			}
648 688
 			foreach($data->getPriorities() as $priority)
649 689
 			{
650
-				foreach($data->itemsAtPriority($priority) as $index => $item)
651
-					$this->insertAtIndexInPriority($item, $index, $priority);
690
+				foreach($data->itemsAtPriority($priority) as $index => $item) {
691
+									$this->insertAtIndexInPriority($item, $index, $priority);
692
+				}
652 693
 			}
653 694
 		} elseif(is_array($data) || $data instanceof \Traversable) {
654
-			if($this->getCount() > 0)
655
-				$this->clear();
656
-			foreach($data as $key => $item)
657
-				$this->add($item);
658
-		} elseif($data !== null)
659
-			throw new TInvalidDataTypeException('map_data_not_iterable');
695
+			if($this->getCount() > 0) {
696
+							$this->clear();
697
+			}
698
+			foreach($data as $key => $item) {
699
+							$this->add($item);
700
+			}
701
+		} elseif($data !== null) {
702
+					throw new TInvalidDataTypeException('map_data_not_iterable');
703
+		}
660 704
 	}
661 705
 
662 706
 	/**
@@ -673,18 +717,19 @@  discard block
 block discarded – undo
673 717
 		{
674 718
 			foreach($data->getPriorities() as $priority)
675 719
 			{
676
-				foreach($data->itemsAtPriority($priority) as $index => $item)
677
-					$this->insertAtIndexInPriority($item, false, $priority);
720
+				foreach($data->itemsAtPriority($priority) as $index => $item) {
721
+									$this->insertAtIndexInPriority($item, false, $priority);
722
+				}
678 723
 			}
679
-		}
680
-		elseif(is_array($data) || $data instanceof \Traversable)
724
+		} elseif(is_array($data) || $data instanceof \Traversable)
681 725
 		{
682
-			foreach($data as $priority => $item)
683
-				$this->add($item);
726
+			foreach($data as $priority => $item) {
727
+							$this->add($item);
728
+			}
684 729
 
730
+		} elseif($data !== null) {
731
+					throw new TInvalidDataTypeException('map_data_not_iterable');
685 732
 		}
686
-		elseif($data !== null)
687
-			throw new TInvalidDataTypeException('map_data_not_iterable');
688 733
 	}
689 734
 
690 735
 	/**
@@ -723,8 +768,9 @@  discard block
 block discarded – undo
723 768
 	 */
724 769
 	public function offsetSet($offset, $item)
725 770
 	{
726
-		if($offset === null)
727
-			return $this->add($item);
771
+		if($offset === null) {
772
+					return $this->add($item);
773
+		}
728 774
 		if($offset === $this->getCount()) {
729 775
 			$priority = $this->priorityAt($offset - 1, true);
730 776
 			$priority[1]++;
Please login to merge, or discard this patch.
framework/Collections/TQueue.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function __construct($data = null)
58 58
 	{
59
-		if($data !== null)
59
+		if ($data !== null)
60 60
 			$this->copyFrom($data);
61 61
 	}
62 62
 
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function copyFrom($data)
78 78
 	{
79
-		if(is_array($data) || ($data instanceof \Traversable))
79
+		if (is_array($data) || ($data instanceof \Traversable))
80 80
 		{
81 81
 			$this->clear();
82
-			foreach($data as $item)
82
+			foreach ($data as $item)
83 83
 			{
84 84
 				$this->_d[] = $item;
85 85
 				++$this->_c;
86 86
 			}
87 87
 		}
88
-		elseif($data !== null)
88
+		elseif ($data !== null)
89 89
 			throw new TInvalidDataTypeException('queue_data_not_iterable');
90 90
 	}
91 91
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	public function peek()
117 117
 	{
118
-		if($this->_c === 0)
118
+		if ($this->_c === 0)
119 119
 			throw new TInvalidOperationException('queue_empty');
120 120
 		else
121 121
 			return $this->_d[0];
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public function dequeue()
130 130
 	{
131
-		if($this->_c === 0)
131
+		if ($this->_c === 0)
132 132
 			throw new TInvalidOperationException('queue_empty');
133 133
 		else
134 134
 		{
Please login to merge, or discard this patch.
Braces   +13 added lines, -11 removed lines patch added patch discarded remove patch
@@ -56,8 +56,9 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function __construct($data = null)
58 58
 	{
59
-		if($data !== null)
60
-			$this->copyFrom($data);
59
+		if($data !== null) {
60
+					$this->copyFrom($data);
61
+		}
61 62
 	}
62 63
 
63 64
 	/**
@@ -84,9 +85,9 @@  discard block
 block discarded – undo
84 85
 				$this->_d[] = $item;
85 86
 				++$this->_c;
86 87
 			}
88
+		} elseif($data !== null) {
89
+					throw new TInvalidDataTypeException('queue_data_not_iterable');
87 90
 		}
88
-		elseif($data !== null)
89
-			throw new TInvalidDataTypeException('queue_data_not_iterable');
90 91
 	}
91 92
 
92 93
 	/**
@@ -115,10 +116,11 @@  discard block
 block discarded – undo
115 116
 	 */
116 117
 	public function peek()
117 118
 	{
118
-		if($this->_c === 0)
119
-			throw new TInvalidOperationException('queue_empty');
120
-		else
121
-			return $this->_d[0];
119
+		if($this->_c === 0) {
120
+					throw new TInvalidOperationException('queue_empty');
121
+		} else {
122
+					return $this->_d[0];
123
+		}
122 124
 	}
123 125
 
124 126
 	/**
@@ -128,9 +130,9 @@  discard block
 block discarded – undo
128 130
 	 */
129 131
 	public function dequeue()
130 132
 	{
131
-		if($this->_c === 0)
132
-			throw new TInvalidOperationException('queue_empty');
133
-		else
133
+		if($this->_c === 0) {
134
+					throw new TInvalidOperationException('queue_empty');
135
+		} else
134 136
 		{
135 137
 			--$this->_c;
136 138
 			return array_shift($this->_d);
Please login to merge, or discard this patch.
framework/Collections/TStack.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function __construct($data = null)
57 57
 	{
58
-		if($data !== null)
58
+		if ($data !== null)
59 59
 			$this->copyFrom($data);
60 60
 	}
61 61
 
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function copyFrom($data)
77 77
 	{
78
-		if(is_array($data) || ($data instanceof \Traversable))
78
+		if (is_array($data) || ($data instanceof \Traversable))
79 79
 		{
80 80
 			$this->clear();
81
-			foreach($data as $item)
81
+			foreach ($data as $item)
82 82
 			{
83 83
 				$this->_d[] = $item;
84 84
 				++$this->_c;
85 85
 			}
86 86
 		}
87
-		elseif($data !== null)
87
+		elseif ($data !== null)
88 88
 			throw new TInvalidDataTypeException('stack_data_not_iterable');
89 89
 	}
90 90
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function peek()
116 116
 	{
117
-		if($this->_c === 0)
117
+		if ($this->_c === 0)
118 118
 			throw new TInvalidOperationException('stack_empty');
119 119
 		else
120 120
 			return $this->_d[$this->_c - 1];
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function pop()
129 129
 	{
130
-		if($this->_c === 0)
130
+		if ($this->_c === 0)
131 131
 			throw new TInvalidOperationException('stack_empty');
132 132
 		else
133 133
 		{
Please login to merge, or discard this patch.
Braces   +13 added lines, -11 removed lines patch added patch discarded remove patch
@@ -55,8 +55,9 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function __construct($data = null)
57 57
 	{
58
-		if($data !== null)
59
-			$this->copyFrom($data);
58
+		if($data !== null) {
59
+					$this->copyFrom($data);
60
+		}
60 61
 	}
61 62
 
62 63
 	/**
@@ -83,9 +84,9 @@  discard block
 block discarded – undo
83 84
 				$this->_d[] = $item;
84 85
 				++$this->_c;
85 86
 			}
87
+		} elseif($data !== null) {
88
+					throw new TInvalidDataTypeException('stack_data_not_iterable');
86 89
 		}
87
-		elseif($data !== null)
88
-			throw new TInvalidDataTypeException('stack_data_not_iterable');
89 90
 	}
90 91
 
91 92
 	/**
@@ -114,10 +115,11 @@  discard block
 block discarded – undo
114 115
 	 */
115 116
 	public function peek()
116 117
 	{
117
-		if($this->_c === 0)
118
-			throw new TInvalidOperationException('stack_empty');
119
-		else
120
-			return $this->_d[$this->_c - 1];
118
+		if($this->_c === 0) {
119
+					throw new TInvalidOperationException('stack_empty');
120
+		} else {
121
+					return $this->_d[$this->_c - 1];
122
+		}
121 123
 	}
122 124
 
123 125
 	/**
@@ -127,9 +129,9 @@  discard block
 block discarded – undo
127 129
 	 */
128 130
 	public function pop()
129 131
 	{
130
-		if($this->_c === 0)
131
-			throw new TInvalidOperationException('stack_empty');
132
-		else
132
+		if($this->_c === 0) {
133
+					throw new TInvalidOperationException('stack_empty');
134
+		} else
133 135
 		{
134 136
 			--$this->_c;
135 137
 			return array_pop($this->_d);
Please login to merge, or discard this patch.
framework/Collections/TAttributeCollection.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function __get($name)
68 68
 	{
69
-		return $this->contains($name)?$this->itemAt($name):parent::__get($name);
69
+		return $this->contains($name) ? $this->itemAt($name) : parent::__get($name);
70 70
 	}
71 71
 
72 72
 	/**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function itemAt($key)
108 108
 	{
109
-		return parent::itemAt($this->_caseSensitive?$key:strtolower($key));
109
+		return parent::itemAt($this->_caseSensitive ? $key : strtolower($key));
110 110
 	}
111 111
 
112 112
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function add($key, $value)
120 120
 	{
121
-		parent::add($this->_caseSensitive?$key:strtolower($key), $value);
121
+		parent::add($this->_caseSensitive ? $key : strtolower($key), $value);
122 122
 	}
123 123
 
124 124
 	/**
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public function remove($key)
131 131
 	{
132
-		return parent::remove($this->_caseSensitive?$key:strtolower($key));
132
+		return parent::remove($this->_caseSensitive ? $key : strtolower($key));
133 133
 	}
134 134
 
135 135
 	/**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public function contains($key)
142 142
 	{
143
-		return parent::contains($this->_caseSensitive?$key:strtolower($key));
143
+		return parent::contains($this->_caseSensitive ? $key : strtolower($key));
144 144
 	}
145 145
 
146 146
 	/**
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,8 +52,9 @@
 block discarded – undo
52 52
 	protected function _getZappableSleepProps(&$exprops)
53 53
 	{
54 54
 		parent::_getZappableSleepProps($exprops);
55
-		if ($this->_caseSensitive === false)
56
-			$exprops[] = "\0Prado\Collections\TAttributeCollection\0_caseSensitive";
55
+		if ($this->_caseSensitive === false) {
56
+					$exprops[] = "\0Prado\Collections\TAttributeCollection\0_caseSensitive";
57
+		}
57 58
 	}
58 59
 
59 60
 	/**
Please login to merge, or discard this patch.
framework/Collections/TPagedDataSource.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function setDataSource($value)
74 74
 	{
75
-		if(!($value instanceof TMap) && !($value instanceof TList))
75
+		if (!($value instanceof TMap) && !($value instanceof TList))
76 76
 		{
77
-			if(is_array($value))
77
+			if (is_array($value))
78 78
 				$value = new TMap($value);
79
-			elseif($value instanceof \Traversable)
79
+			elseif ($value instanceof \Traversable)
80 80
 				$value = new TList($value);
81
-			elseif($value !== null)
81
+			elseif ($value !== null)
82 82
 				throw new TInvalidDataTypeException('pageddatasource_datasource_invalid');
83 83
 		}
84 84
 		$this->_dataSource = $value;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function setPageSize($value)
99 99
 	{
100
-		if(($value = TPropertyValue::ensureInteger($value)) > 0)
100
+		if (($value = TPropertyValue::ensureInteger($value)) > 0)
101 101
 			$this->_pageSize = $value;
102 102
 		else
103 103
 			throw new TInvalidDataValueException('pageddatasource_pagesize_invalid');
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function setCurrentPageIndex($value)
118 118
 	{
119
-		if(($value = TPropertyValue::ensureInteger($value)) < 0)
119
+		if (($value = TPropertyValue::ensureInteger($value)) < 0)
120 120
 			$value = 0;
121 121
 		$this->_currentPageIndex = $value;
122 122
 	}
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public function setVirtualItemCount($value)
168 168
 	{
169
-		if(($value = TPropertyValue::ensureInteger($value)) >= 0)
169
+		if (($value = TPropertyValue::ensureInteger($value)) >= 0)
170 170
 			$this->_virtualCount = $value;
171 171
 		else
172 172
 			throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid');
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	public function getCount()
179 179
 	{
180
-		if($this->_dataSource === null)
180
+		if ($this->_dataSource === null)
181 181
 			return 0;
182
-		if(!$this->_allowPaging)
182
+		if (!$this->_allowPaging)
183 183
 			return $this->getDataSourceCount();
184
-		if(!$this->_allowCustomPaging && $this->getIsLastPage())
184
+		if (!$this->_allowCustomPaging && $this->getIsLastPage())
185 185
 			return $this->getDataSourceCount() - $this->getFirstIndexInPage();
186 186
 		return $this->_pageSize;
187 187
 	}
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
 	 */
202 202
 	public function getPageCount()
203 203
 	{
204
-		if($this->_dataSource === null)
204
+		if ($this->_dataSource === null)
205 205
 			return 0;
206 206
 		$count = $this->getDataSourceCount();
207
-		if(!$this->_allowPaging || $count <= 0)
207
+		if (!$this->_allowPaging || $count <= 0)
208 208
 			return 1;
209
-		return (int)(($count + $this->_pageSize - 1) / $this->_pageSize);
209
+		return (int) (($count + $this->_pageSize - 1) / $this->_pageSize);
210 210
 	}
211 211
 
212 212
 	/**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function getIsFirstPage()
216 216
 	{
217
-		if($this->_allowPaging)
217
+		if ($this->_allowPaging)
218 218
 			return $this->_currentPageIndex === 0;
219 219
 		else
220 220
 			return true;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	public function getIsLastPage()
227 227
 	{
228
-		if($this->_allowPaging)
228
+		if ($this->_allowPaging)
229 229
 			return $this->_currentPageIndex === $this->getPageCount() - 1;
230 230
 		else
231 231
 			return true;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	public function getFirstIndexInPage()
239 239
 	{
240
-		if($this->_dataSource !== null && $this->_allowPaging && !$this->_allowCustomPaging)
240
+		if ($this->_dataSource !== null && $this->_allowPaging && !$this->_allowCustomPaging)
241 241
 			return $this->_currentPageIndex * $this->_pageSize;
242 242
 		else
243 243
 			return 0;
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 */
249 249
 	public function getDataSourceCount()
250 250
 	{
251
-		if($this->_dataSource === null)
251
+		if ($this->_dataSource === null)
252 252
 			return 0;
253
-		elseif($this->_allowCustomPaging)
253
+		elseif ($this->_allowCustomPaging)
254 254
 			return $this->_virtualCount;
255 255
 		else
256 256
 			return $this->_dataSource->getCount();
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function getIterator()
263 263
 	{
264
-		if($this->_dataSource instanceof TList)
264
+		if ($this->_dataSource instanceof TList)
265 265
 			return new TPagedListIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount());
266
-		elseif($this->_dataSource instanceof TMap)
266
+		elseif ($this->_dataSource instanceof TMap)
267 267
 			return new TPagedMapIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount());
268 268
 		else
269 269
 			return null;
Please login to merge, or discard this patch.
Braces   +64 added lines, -50 removed lines patch added patch discarded remove patch
@@ -74,12 +74,13 @@  discard block
 block discarded – undo
74 74
 	{
75 75
 		if(!($value instanceof TMap) && !($value instanceof TList))
76 76
 		{
77
-			if(is_array($value))
78
-				$value = new TMap($value);
79
-			elseif($value instanceof \Traversable)
80
-				$value = new TList($value);
81
-			elseif($value !== null)
82
-				throw new TInvalidDataTypeException('pageddatasource_datasource_invalid');
77
+			if(is_array($value)) {
78
+							$value = new TMap($value);
79
+			} elseif($value instanceof \Traversable) {
80
+							$value = new TList($value);
81
+			} elseif($value !== null) {
82
+							throw new TInvalidDataTypeException('pageddatasource_datasource_invalid');
83
+			}
83 84
 		}
84 85
 		$this->_dataSource = $value;
85 86
 	}
@@ -97,10 +98,11 @@  discard block
 block discarded – undo
97 98
 	 */
98 99
 	public function setPageSize($value)
99 100
 	{
100
-		if(($value = TPropertyValue::ensureInteger($value)) > 0)
101
-			$this->_pageSize = $value;
102
-		else
103
-			throw new TInvalidDataValueException('pageddatasource_pagesize_invalid');
101
+		if(($value = TPropertyValue::ensureInteger($value)) > 0) {
102
+					$this->_pageSize = $value;
103
+		} else {
104
+					throw new TInvalidDataValueException('pageddatasource_pagesize_invalid');
105
+		}
104 106
 	}
105 107
 
106 108
 	/**
@@ -116,8 +118,9 @@  discard block
 block discarded – undo
116 118
 	 */
117 119
 	public function setCurrentPageIndex($value)
118 120
 	{
119
-		if(($value = TPropertyValue::ensureInteger($value)) < 0)
120
-			$value = 0;
121
+		if(($value = TPropertyValue::ensureInteger($value)) < 0) {
122
+					$value = 0;
123
+		}
121 124
 		$this->_currentPageIndex = $value;
122 125
 	}
123 126
 
@@ -166,10 +169,11 @@  discard block
 block discarded – undo
166 169
 	 */
167 170
 	public function setVirtualItemCount($value)
168 171
 	{
169
-		if(($value = TPropertyValue::ensureInteger($value)) >= 0)
170
-			$this->_virtualCount = $value;
171
-		else
172
-			throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid');
172
+		if(($value = TPropertyValue::ensureInteger($value)) >= 0) {
173
+					$this->_virtualCount = $value;
174
+		} else {
175
+					throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid');
176
+		}
173 177
 	}
174 178
 
175 179
 	/**
@@ -177,12 +181,15 @@  discard block
 block discarded – undo
177 181
 	 */
178 182
 	public function getCount()
179 183
 	{
180
-		if($this->_dataSource === null)
181
-			return 0;
182
-		if(!$this->_allowPaging)
183
-			return $this->getDataSourceCount();
184
-		if(!$this->_allowCustomPaging && $this->getIsLastPage())
185
-			return $this->getDataSourceCount() - $this->getFirstIndexInPage();
184
+		if($this->_dataSource === null) {
185
+					return 0;
186
+		}
187
+		if(!$this->_allowPaging) {
188
+					return $this->getDataSourceCount();
189
+		}
190
+		if(!$this->_allowCustomPaging && $this->getIsLastPage()) {
191
+					return $this->getDataSourceCount() - $this->getFirstIndexInPage();
192
+		}
186 193
 		return $this->_pageSize;
187 194
 	}
188 195
 
@@ -201,11 +208,13 @@  discard block
 block discarded – undo
201 208
 	 */
202 209
 	public function getPageCount()
203 210
 	{
204
-		if($this->_dataSource === null)
205
-			return 0;
211
+		if($this->_dataSource === null) {
212
+					return 0;
213
+		}
206 214
 		$count = $this->getDataSourceCount();
207
-		if(!$this->_allowPaging || $count <= 0)
208
-			return 1;
215
+		if(!$this->_allowPaging || $count <= 0) {
216
+					return 1;
217
+		}
209 218
 		return (int)(($count + $this->_pageSize - 1) / $this->_pageSize);
210 219
 	}
211 220
 
@@ -214,10 +223,11 @@  discard block
 block discarded – undo
214 223
 	 */
215 224
 	public function getIsFirstPage()
216 225
 	{
217
-		if($this->_allowPaging)
218
-			return $this->_currentPageIndex === 0;
219
-		else
220
-			return true;
226
+		if($this->_allowPaging) {
227
+					return $this->_currentPageIndex === 0;
228
+		} else {
229
+					return true;
230
+		}
221 231
 	}
222 232
 
223 233
 	/**
@@ -225,10 +235,11 @@  discard block
 block discarded – undo
225 235
 	 */
226 236
 	public function getIsLastPage()
227 237
 	{
228
-		if($this->_allowPaging)
229
-			return $this->_currentPageIndex === $this->getPageCount() - 1;
230
-		else
231
-			return true;
238
+		if($this->_allowPaging) {
239
+					return $this->_currentPageIndex === $this->getPageCount() - 1;
240
+		} else {
241
+					return true;
242
+		}
232 243
 	}
233 244
 
234 245
 	/**
@@ -237,10 +248,11 @@  discard block
 block discarded – undo
237 248
 	 */
238 249
 	public function getFirstIndexInPage()
239 250
 	{
240
-		if($this->_dataSource !== null && $this->_allowPaging && !$this->_allowCustomPaging)
241
-			return $this->_currentPageIndex * $this->_pageSize;
242
-		else
243
-			return 0;
251
+		if($this->_dataSource !== null && $this->_allowPaging && !$this->_allowCustomPaging) {
252
+					return $this->_currentPageIndex * $this->_pageSize;
253
+		} else {
254
+					return 0;
255
+		}
244 256
 	}
245 257
 
246 258
 	/**
@@ -248,12 +260,13 @@  discard block
 block discarded – undo
248 260
 	 */
249 261
 	public function getDataSourceCount()
250 262
 	{
251
-		if($this->_dataSource === null)
252
-			return 0;
253
-		elseif($this->_allowCustomPaging)
254
-			return $this->_virtualCount;
255
-		else
256
-			return $this->_dataSource->getCount();
263
+		if($this->_dataSource === null) {
264
+					return 0;
265
+		} elseif($this->_allowCustomPaging) {
266
+					return $this->_virtualCount;
267
+		} else {
268
+					return $this->_dataSource->getCount();
269
+		}
257 270
 	}
258 271
 
259 272
 	/**
@@ -261,11 +274,12 @@  discard block
 block discarded – undo
261 274
 	 */
262 275
 	public function getIterator()
263 276
 	{
264
-		if($this->_dataSource instanceof TList)
265
-			return new TPagedListIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount());
266
-		elseif($this->_dataSource instanceof TMap)
267
-			return new TPagedMapIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount());
268
-		else
269
-			return null;
277
+		if($this->_dataSource instanceof TList) {
278
+					return new TPagedListIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount());
279
+		} elseif($this->_dataSource instanceof TMap) {
280
+					return new TPagedMapIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount());
281
+		} else {
282
+					return null;
283
+		}
270 284
 	}
271 285
 }
272 286
\ No newline at end of file
Please login to merge, or discard this patch.