Passed
Branch php-cs-fixer (b9836a)
by Fabio
15:58
created
framework/I18N/core/MessageCache.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 use Exception;
14 14
 
15
-require_once(dirname(__FILE__) . '/TCache_Lite.php');
15
+require_once(dirname(__FILE__).'/TCache_Lite.php');
16 16
 
17 17
 /**
18 18
  * Cache the translation table into the file system.
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public function __construct($cacheDir)
43 43
 	{
44
-		$cacheDir = $cacheDir . '/';
44
+		$cacheDir = $cacheDir.'/';
45 45
 
46
-		if(!is_dir($cacheDir))
46
+		if (!is_dir($cacheDir))
47 47
 			throw new Exception(
48
-				'The cache directory ' . $cacheDir . ' does not exists.' .
48
+				'The cache directory '.$cacheDir.' does not exists.'.
49 49
 				'The cache directory must be writable by the server.');
50
-		if(!is_writable($cacheDir))
50
+		if (!is_writable($cacheDir))
51 51
 			throw new Exception(
52
-				'The cache directory ' . $cacheDir . ' must be writable ' .
52
+				'The cache directory '.$cacheDir.' must be writable '.
53 53
 				'by the server.');
54 54
 
55 55
 		$options = [
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function setLifeTime($time)
78 78
 	{
79
-		$this->lifetime = (int)$time;
79
+		$this->lifetime = (int) $time;
80 80
 	}
81 81
 
82 82
 	/**
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	protected function getID($catalogue, $culture)
88 88
 	{
89
-		return $catalogue . ':' . $culture;
89
+		return $catalogue.':'.$culture;
90 90
 	}
91 91
 
92 92
 	/**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	protected function getGroup($catalogue, $culture)
98 98
 	{
99
-		return $catalogue . ':' . get_class($this);
99
+		return $catalogue.':'.get_class($this);
100 100
 	}
101 101
 
102 102
 	/**
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
 
118 118
 		$cache = $this->cache->getCacheFile();
119 119
 
120
-		if(is_file($cache) == false)
120
+		if (is_file($cache) == false)
121 121
 			return false;
122 122
 
123 123
 
124
-		$lastmodified = (int)$lastmodified;
124
+		$lastmodified = (int) $lastmodified;
125 125
 
126
-		if($lastmodified <= 0 || $lastmodified > filemtime($cache))
126
+		if ($lastmodified <= 0 || $lastmodified > filemtime($cache))
127 127
 			return false;
128 128
 
129 129
 		//echo '@@ Cache hit: "'.$ID.'" : "'.$group.'"';
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,14 +43,16 @@  discard block
 block discarded – undo
43 43
 	{
44 44
 		$cacheDir = $cacheDir . '/';
45 45
 
46
-		if(!is_dir($cacheDir))
47
-			throw new Exception(
46
+		if(!is_dir($cacheDir)) {
47
+					throw new Exception(
48 48
 				'The cache directory ' . $cacheDir . ' does not exists.' .
49 49
 				'The cache directory must be writable by the server.');
50
-		if(!is_writable($cacheDir))
51
-			throw new Exception(
50
+		}
51
+		if(!is_writable($cacheDir)) {
52
+					throw new Exception(
52 53
 				'The cache directory ' . $cacheDir . ' must be writable ' .
53 54
 				'by the server.');
55
+		}
54 56
 
55 57
 		$options = [
56 58
 			'cacheDir' => $cacheDir,
@@ -117,14 +119,16 @@  discard block
 block discarded – undo
117 119
 
118 120
 		$cache = $this->cache->getCacheFile();
119 121
 
120
-		if(is_file($cache) == false)
121
-			return false;
122
+		if(is_file($cache) == false) {
123
+					return false;
124
+		}
122 125
 
123 126
 
124 127
 		$lastmodified = (int)$lastmodified;
125 128
 
126
-		if($lastmodified <= 0 || $lastmodified > filemtime($cache))
127
-			return false;
129
+		if($lastmodified <= 0 || $lastmodified > filemtime($cache)) {
130
+					return false;
131
+		}
128 132
 
129 133
 		//echo '@@ Cache hit: "'.$ID.'" : "'.$group.'"';
130 134
 		//echo "<br>\n";
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_PHP.php 2 patches
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function __construct($source)
57 57
 	{
58
-		$this->source = (string)$source;
58
+		$this->source = (string) $source;
59 59
 	}
60 60
 
61 61
 	/**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	protected function &loadData($filename)
67 67
 	{
68 68
 		//load it.
69
-		if(false === ($php = include($filename))) {
69
+		if (false === ($php = include($filename))) {
70 70
 			return false;
71 71
 		}
72 72
 
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 
75 75
 		$translations = [];
76 76
 
77
-		foreach($translationUnit as $k => $unit)
77
+		foreach ($translationUnit as $k => $unit)
78 78
 		{
79
-			$source = (string)$unit['source'];
80
-			$translations[$source][] = (string)$unit['target'];
81
-			$translations[$source][] = (string)$k;
82
-			$translations[$source][] = array_key_exists('note', $unit) ? (string)$unit['note'] : '';
79
+			$source = (string) $unit['source'];
80
+			$translations[$source][] = (string) $unit['target'];
81
+			$translations[$source][] = (string) $k;
82
+			$translations[$source][] = array_key_exists('note', $unit) ? (string) $unit['note'] : '';
83 83
 		}
84 84
 
85 85
 		return $translations;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	protected function getSource($variant)
106 106
 	{
107
-		return $this->source . '/' . $variant;
107
+		return $this->source.'/'.$variant;
108 108
 	}
109 109
 
110 110
 	/**
@@ -125,16 +125,16 @@  discard block
 block discarded – undo
125 125
 	protected function getCatalogueList($catalogue)
126 126
 	{
127 127
 		$variants = explode('_', $this->culture);
128
-		$source = $catalogue . $this->dataExt;
128
+		$source = $catalogue.$this->dataExt;
129 129
 		$catalogues = [$source];
130 130
 		$variant = null;
131 131
 
132
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
132
+		for ($i = 0, $k = count($variants); $i < $k; ++$i)
133 133
 		{
134
-			if(isset($variants[$i]{0}))
134
+			if (isset($variants[$i]{0}))
135 135
 			{
136
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
137
-				$catalogues[] = $catalogue . $this->dataSeparator . $variant . $this->dataExt;
136
+				$variant .= ($variant) ? '_'.$variants[$i] : $variants[$i];
137
+				$catalogues[] = $catalogue.$this->dataSeparator.$variant.$this->dataExt;
138 138
 			}
139 139
 		}
140 140
 
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
 		$catalogues = [];
156 156
 		$variant = null;
157 157
 
158
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
158
+		for ($i = 0, $k = count($variants); $i < $k; ++$i)
159 159
 		{
160
-			if(isset($variants[$i]{0}))
160
+			if (isset($variants[$i]{0}))
161 161
 			{
162
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
163
-				$catalogues[] = $variant . '/' . $catalogue . $this->dataExt;
162
+				$variant .= ($variant) ? '_'.$variants[$i] : $variants[$i];
163
+				$catalogues[] = $variant.'/'.$catalogue.$this->dataExt;
164 164
 			}
165 165
 		}
166 166
 
@@ -186,28 +186,28 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	protected function getCatalogues($dir = null, $variant = null)
188 188
 	{
189
-		$dir = $dir?$dir:$this->source;
189
+		$dir = $dir ? $dir : $this->source;
190 190
 		$files = scandir($dir);
191 191
 		$catalogue = [];
192 192
 
193
-		foreach($files as $file)
193
+		foreach ($files as $file)
194 194
 		{
195
-			if(is_dir($dir . '/' . $file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file)) {
195
+			if (is_dir($dir.'/'.$file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file)) {
196 196
 				$catalogue = array_merge(
197 197
 					$catalogue,
198
-					$this->getCatalogues($dir . '/' . $file, $file)
198
+					$this->getCatalogues($dir.'/'.$file, $file)
199 199
 				);
200 200
 			}
201 201
 
202 202
 			$pos = strpos($file, $this->dataExt);
203
-			if($pos > 0 && substr($file, -1 * strlen($this->dataExt)) == $this->dataExt)
203
+			if ($pos > 0 && substr($file, -1 * strlen($this->dataExt)) == $this->dataExt)
204 204
 			{
205 205
 				$name = substr($file, 0, $pos);
206 206
 				$dot = strrpos($name, $this->dataSeparator);
207 207
 				$culture = $variant;
208 208
 				$cat = $name;
209 209
 
210
-				if(is_int($dot))
210
+				if (is_int($dot))
211 211
 				{
212 212
 					$culture = substr($name, $dot + 1, strlen($name));
213 213
 					$cat = substr($name, 0, $dot);
@@ -232,14 +232,14 @@  discard block
 block discarded – undo
232 232
 	 */
233 233
 	private function getVariants($catalogue = 'messages')
234 234
 	{
235
-		if($catalogue === null) {
235
+		if ($catalogue === null) {
236 236
 			$catalogue = 'messages';
237 237
 		}
238 238
 
239
-		foreach($this->getCatalogueList($catalogue) as $variant)
239
+		foreach ($this->getCatalogueList($catalogue) as $variant)
240 240
 		{
241 241
 			$file = $this->getSource($variant);
242
-			if(is_file($file)) {
242
+			if (is_file($file)) {
243 243
 				return [$variant, $file];
244 244
 			}
245 245
 		}
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 		$php['info']['date'] = @date('Y-m-d\TH:i:s\Z');
252 252
 
253 253
 		//save it and clear the cache for this variant
254
-		if(false === file_put_contents($filename, "<?php\nreturn " . var_export($php, true) . ';'))
254
+		if (false === file_put_contents($filename, "<?php\nreturn ".var_export($php, true).';'))
255 255
 			return false;
256 256
 
257
-		if(!empty($this->cache))
257
+		if (!empty($this->cache))
258 258
 			$this->cache->clean($variant, $this->culture);
259 259
 
260 260
 		return true;
@@ -270,19 +270,19 @@  discard block
 block discarded – undo
270 270
 	public function save($catalogue = 'messages')
271 271
 	{
272 272
 		$messages = $this->untranslated;
273
-		if(count($messages) <= 0) {
273
+		if (count($messages) <= 0) {
274 274
 			return false;
275 275
 		}
276 276
 
277 277
 		$variants = $this->getVariants($catalogue);
278 278
 
279
-		if($variants) {
279
+		if ($variants) {
280 280
 			list($variant, $filename) = $variants;
281 281
 		} else {
282 282
 			list($variant, $filename) = $this->createMessageTemplate($catalogue);
283 283
 		}
284 284
 
285
-		if(is_writable($filename) == false) {
285
+		if (is_writable($filename) == false) {
286 286
 			throw new TIOException("Unable to save to file {$filename}, file must be writable.");
287 287
 		}
288 288
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 		$php = include($filename);
291 291
 
292 292
 		//for each message add it to the XML file using DOM
293
-		foreach($messages as $message)
293
+		foreach ($messages as $message)
294 294
 		{
295 295
 			$php['trans-unit'][] = [
296 296
 				'source' => $message,
@@ -313,13 +313,13 @@  discard block
 block discarded – undo
313 313
 	{
314 314
 		$variants = $this->getVariants($catalogue);
315 315
 
316
-		if($variants) {
316
+		if ($variants) {
317 317
 			list($variant, $filename) = $variants;
318 318
 		} else {
319 319
 			return false;
320 320
 		}
321 321
 
322
-		if(is_writable($filename) == false) {
322
+		if (is_writable($filename) == false) {
323 323
 			throw new TIOException("Unable to update file {$filename}, file must be writable.");
324 324
 		}
325 325
 
@@ -327,12 +327,12 @@  discard block
 block discarded – undo
327 327
 		$php = include($filename);
328 328
 
329 329
 		//for each of the existin units
330
-		foreach($php['trans-unit'] as $k => $unit)
330
+		foreach ($php['trans-unit'] as $k => $unit)
331 331
 		{
332
-			if($unit['source'] == $text)
332
+			if ($unit['source'] == $text)
333 333
 			{
334 334
 				$php['trans-unit'][$k]['target'] = $target;
335
-				if(!empty($comments))
335
+				if (!empty($comments))
336 336
 					$php['trans-unit'][$k]['note'] = $comments;
337 337
 
338 338
 				break;
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
 	public function delete($message, $catalogue = 'messages')
352 352
 	{
353 353
 		$variants = $this->getVariants($catalogue);
354
-		if($variants) {
354
+		if ($variants) {
355 355
 			list($variant, $filename) = $variants;
356 356
 		} else {
357 357
 			return false;
358 358
 		}
359 359
 
360
-		if(is_writable($filename) == false) {
360
+		if (is_writable($filename) == false) {
361 361
 			throw new TIOException("Unable to modify file {$filename}, file must be writable.");
362 362
 		}
363 363
 
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
 		$php = include($filename);
366 366
 
367 367
 		//for each of the existin units
368
-		foreach($php['trans-unit'] as $k => $unit)
368
+		foreach ($php['trans-unit'] as $k => $unit)
369 369
 		{
370
-			if($unit['source'] == $message)
370
+			if ($unit['source'] == $message)
371 371
 			{
372 372
 				unset($php['trans-unit'][$k]);
373 373
 				return $this->internalSaveFile($php, $filename, $variant);
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 
380 380
 	protected function createMessageTemplate($catalogue)
381 381
 	{
382
-		if($catalogue === null) {
382
+		if ($catalogue === null) {
383 383
 			$catalogue = 'messages';
384 384
 		}
385 385
 		
@@ -388,12 +388,12 @@  discard block
 block discarded – undo
388 388
 		$file = $this->getSource($variant);
389 389
 		$dir = dirname($file);
390 390
 
391
-		if(!is_dir($dir)) {
391
+		if (!is_dir($dir)) {
392 392
 			@mkdir($dir);
393 393
 			@chmod($dir, PRADO_CHMOD);
394 394
 		}
395 395
 
396
-		if(!is_dir($dir)) {
396
+		if (!is_dir($dir)) {
397 397
 			throw new TException("Unable to create directory $dir");
398 398
 		}
399 399
 		
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -251,11 +251,13 @@  discard block
 block discarded – undo
251 251
 		$php['info']['date'] = @date('Y-m-d\TH:i:s\Z');
252 252
 
253 253
 		//save it and clear the cache for this variant
254
-		if(false === file_put_contents($filename, "<?php\nreturn " . var_export($php, true) . ';'))
255
-			return false;
254
+		if(false === file_put_contents($filename, "<?php\nreturn " . var_export($php, true) . ';')) {
255
+					return false;
256
+		}
256 257
 
257
-		if(!empty($this->cache))
258
-			$this->cache->clean($variant, $this->culture);
258
+		if(!empty($this->cache)) {
259
+					$this->cache->clean($variant, $this->culture);
260
+		}
259 261
 
260 262
 		return true;
261 263
 	}
@@ -332,8 +334,9 @@  discard block
 block discarded – undo
332 334
 			if($unit['source'] == $text)
333 335
 			{
334 336
 				$php['trans-unit'][$k]['target'] = $target;
335
-				if(!empty($comments))
336
-					$php['trans-unit'][$k]['note'] = $comments;
337
+				if(!empty($comments)) {
338
+									$php['trans-unit'][$k]['note'] = $comments;
339
+				}
337 340
 
338 341
 				break;
339 342
 			}
Please login to merge, or discard this patch.
framework/I18N/core/util.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	function I18N_toUTF8($string, $from)
164 164
 	{
165
-		if($from != 'UTF-8')
165
+		if ($from != 'UTF-8')
166 166
 		{
167 167
 			$s = iconv($from, 'UTF-8', $string); //to UTF-8
168 168
 			return $s !== false ? $s : $string; //it could return false
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 */
179 179
 	function I18N_toEncoding($string, $to)
180 180
 	{
181
-		if($to != 'UTF-8')
181
+		if ($to != 'UTF-8')
182 182
 		{
183 183
 			$s = iconv('UTF-8', $to, $string);
184 184
 			return $s !== false ? $s : $string;
Please login to merge, or discard this patch.
framework/I18N/core/NumberFormatInfo.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 use Exception;
25 25
 
26
-require_once(dirname(__FILE__) . '/CultureInfo.php');
26
+require_once(dirname(__FILE__).'/CultureInfo.php');
27 27
 
28 28
 /**
29 29
  * NumberFormatInfo class
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function __get($name)
82 82
 	{
83
-		$getProperty = 'get' . $name;
84
-		if(in_array($getProperty, $this->properties))
83
+		$getProperty = 'get'.$name;
84
+		if (in_array($getProperty, $this->properties))
85 85
 			return $this->$getProperty();
86 86
 		else
87
-			throw new Exception('Property ' . $name . ' does not exists.');
87
+			throw new Exception('Property '.$name.' does not exists.');
88 88
 	}
89 89
 
90 90
 	/**
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public function __set($name, $value)
95 95
 	{
96
-		$setProperty = 'set' . $name;
97
-		if(in_array($setProperty, $this->properties))
96
+		$setProperty = 'set'.$name;
97
+		if (in_array($setProperty, $this->properties))
98 98
 			$this->$setProperty($value);
99 99
 		else
100
-			throw new Exception('Property ' . $name . ' can not be set.');
100
+			throw new Exception('Property '.$name.' can not be set.');
101 101
 	}
102 102
 
103 103
 	/**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	{
114 114
 		$this->properties = get_class_methods($this);
115 115
 
116
-		if(empty($data))
116
+		if (empty($data))
117 117
 			throw new Exception('Please provide the ICU data to initialize.');
118 118
 
119 119
 		$this->data = $data;
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public function setPattern($type = NumberFormatInfo::DECIMAL)
131 131
 	{
132
-		if(is_int($type))
132
+		if (is_int($type))
133 133
 			$this->pattern =
134 134
 				$this->parsePattern($this->data['NumberPatterns'][$type]);
135 135
 		else
136 136
 			$this->pattern = $this->parsePattern($type);
137 137
 
138 138
 		$this->pattern['negInfty'] =
139
-			$this->data['NumberElements'][6] .
139
+			$this->data['NumberElements'][6].
140 140
 			$this->data['NumberElements'][9];
141 141
 
142 142
 		$this->pattern['posInfty'] =
143
-			$this->data['NumberElements'][11] .
143
+			$this->data['NumberElements'][11].
144 144
 			$this->data['NumberElements'][9];
145 145
 	}
146 146
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	public static function getInvariantInfo($type = NumberFormatInfo::DECIMAL)
158 158
 	{
159 159
 		static $invariant;
160
-		if($invariant === null)
160
+		if ($invariant === null)
161 161
 		{
162 162
 			$culture = CultureInfo::getInvariantCulture();
163 163
 			$invariant = $culture->NumberFormat;
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 			$formatInfo->setPattern($type);
188 188
 			return $formatInfo;
189 189
 		}
190
-		   elseif(is_string($culture))
190
+		   elseif (is_string($culture))
191 191
 		   {
192 192
 			   $cultureInfo = new CultureInfo($culture);
193 193
 			   $formatInfo = $cultureInfo->NumberFormat;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 		$pattern = explode(';', $pattern);
247 247
 
248 248
 		$negative = null;
249
-		if(count($pattern) > 1)
249
+		if (count($pattern) > 1)
250 250
 			$negative = $pattern[1];
251 251
 		$pattern = $pattern[0];
252 252
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 		$groupPos2 = false;
263 263
 		$groupSize1 = false;
264 264
 		$groupSize2 = false;
265
-		$decimalPoints = is_int($decimalPos)?-1:false;
265
+		$decimalPoints = is_int($decimalPos) ?-1 : false;
266 266
 
267 267
 		$info['negPref'] = $this->data['NumberElements'][6];
268 268
 		$info['negPost'] = '';
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 		$info['positive'] = $pattern;
272 272
 
273 273
 		//find the negative prefix and postfix
274
-		if($negative)
274
+		if ($negative)
275 275
 		{
276 276
 			$prefixPostfix = $this->getPrePostfix($negative);
277 277
 			$info['negPref'] = $prefixPostfix[0];
@@ -284,13 +284,13 @@  discard block
 block discarded – undo
284 284
 
285 285
 		//var_dump($pattern);
286 286
 		//var_dump($decimalPos);
287
-		if(is_int($groupPos1))
287
+		if (is_int($groupPos1))
288 288
 		{
289 289
 			//get the second group
290 290
 			$groupPos2 = strrpos(substr($pattern, 0, $groupPos1), $comma);
291 291
 
292 292
 			//get the number of decimal digits
293
-			if(is_int($decimalPos))
293
+			if (is_int($decimalPos))
294 294
 			{
295 295
 				$groupSize1 = $decimalPos - $groupPos1 - 1;
296 296
 
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 			{
300 300
 				//no decimal point, so traverse from the back
301 301
 				//to find the groupsize 1.
302
-				for($i = strlen($pattern) - 1; $i >= 0; $i--)
302
+				for ($i = strlen($pattern) - 1; $i >= 0; $i--)
303 303
 				{
304
-					if($pattern{$i} == $digit || $pattern{$i} == $hash)
304
+					if ($pattern{$i} == $digit || $pattern{$i} == $hash)
305 305
 					{
306 306
 						$groupSize1 = $i - $groupPos1;
307 307
 						break;
@@ -310,16 +310,16 @@  discard block
 block discarded – undo
310 310
 			}
311 311
 
312 312
 			//get the second group size
313
-			if(is_int($groupPos2))
313
+			if (is_int($groupPos2))
314 314
 				$groupSize2 = $groupPos1 - $groupPos2 - 1;
315 315
 		}
316 316
 
317
-		if(is_int($decimalPos))
317
+		if (is_int($decimalPos))
318 318
 		{
319
-			for($i = strlen($pattern) - 1; $i >= 0; $i--)
319
+			for ($i = strlen($pattern) - 1; $i >= 0; $i--)
320 320
 			{
321
-				if($pattern{$i} == $dot) break;
322
-				if($pattern{$i} == $digit)
321
+				if ($pattern{$i} == $dot) break;
322
+				if ($pattern{$i} == $digit)
323 323
 				{
324 324
 					$decimalPoints = $i - $decimalPos;
325 325
 					break;
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			}
328 328
 		}
329 329
 
330
-		if(is_int($decimalPos))
330
+		if (is_int($decimalPos))
331 331
 			$digitPattern = substr($pattern, 0, $decimalPos);
332 332
 		else
333 333
 			$digitPattern = $pattern;
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 	{
354 354
 		$regexp = '/[#,\.0]+/';
355 355
 		$result = preg_split($regexp, $pattern);
356
-		return [$result[0],$result[1]];
356
+		return [$result[0], $result[1]];
357 357
 	}
358 358
 
359 359
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 	 */
508 508
 	public function getCurrencySymbol($currency = 'USD')
509 509
 	{
510
-		if(isset($this->pattern['symbol']))
510
+		if (isset($this->pattern['symbol']))
511 511
 			return $this->pattern['symbol'];
512 512
 		else
513 513
 			return $this->data['Currencies'][$currency][0];
Please login to merge, or discard this patch.
Braces   +40 added lines, -33 removed lines patch added patch discarded remove patch
@@ -81,10 +81,11 @@  discard block
 block discarded – undo
81 81
 	public function __get($name)
82 82
 	{
83 83
 		$getProperty = 'get' . $name;
84
-		if(in_array($getProperty, $this->properties))
85
-			return $this->$getProperty();
86
-		else
87
-			throw new Exception('Property ' . $name . ' does not exists.');
84
+		if(in_array($getProperty, $this->properties)) {
85
+					return $this->$getProperty();
86
+		} else {
87
+					throw new Exception('Property ' . $name . ' does not exists.');
88
+		}
88 89
 	}
89 90
 
90 91
 	/**
@@ -94,10 +95,11 @@  discard block
 block discarded – undo
94 95
 	public function __set($name, $value)
95 96
 	{
96 97
 		$setProperty = 'set' . $name;
97
-		if(in_array($setProperty, $this->properties))
98
-			$this->$setProperty($value);
99
-		else
100
-			throw new Exception('Property ' . $name . ' can not be set.');
98
+		if(in_array($setProperty, $this->properties)) {
99
+					$this->$setProperty($value);
100
+		} else {
101
+					throw new Exception('Property ' . $name . ' can not be set.');
102
+		}
101 103
 	}
102 104
 
103 105
 	/**
@@ -113,8 +115,9 @@  discard block
 block discarded – undo
113 115
 	{
114 116
 		$this->properties = get_class_methods($this);
115 117
 
116
-		if(empty($data))
117
-			throw new Exception('Please provide the ICU data to initialize.');
118
+		if(empty($data)) {
119
+					throw new Exception('Please provide the ICU data to initialize.');
120
+		}
118 121
 
119 122
 		$this->data = $data;
120 123
 
@@ -129,11 +132,12 @@  discard block
 block discarded – undo
129 132
 	 */
130 133
 	public function setPattern($type = NumberFormatInfo::DECIMAL)
131 134
 	{
132
-		if(is_int($type))
133
-			$this->pattern =
135
+		if(is_int($type)) {
136
+					$this->pattern =
134 137
 				$this->parsePattern($this->data['NumberPatterns'][$type]);
135
-		else
136
-			$this->pattern = $this->parsePattern($type);
138
+		} else {
139
+					$this->pattern = $this->parsePattern($type);
140
+		}
137 141
 
138 142
 		$this->pattern['negInfty'] =
139 143
 			$this->data['NumberElements'][6] .
@@ -186,15 +190,13 @@  discard block
 block discarded – undo
186 190
 			$formatInfo = $culture->NumberFormat;
187 191
 			$formatInfo->setPattern($type);
188 192
 			return $formatInfo;
189
-		}
190
-		   elseif(is_string($culture))
193
+		} elseif(is_string($culture))
191 194
 		   {
192 195
 			   $cultureInfo = new CultureInfo($culture);
193 196
 			   $formatInfo = $cultureInfo->NumberFormat;
194 197
 			   $formatInfo->setPattern($type);
195 198
 			   return $formatInfo;
196
-		   }
197
-		   else
199
+		   } else
198 200
 		   {
199 201
 			$cultureInfo = new CultureInfo();
200 202
 			   $formatInfo = $cultureInfo->NumberFormat;
@@ -246,8 +248,9 @@  discard block
 block discarded – undo
246 248
 		$pattern = explode(';', $pattern);
247 249
 
248 250
 		$negative = null;
249
-		if(count($pattern) > 1)
250
-			$negative = $pattern[1];
251
+		if(count($pattern) > 1) {
252
+					$negative = $pattern[1];
253
+		}
251 254
 		$pattern = $pattern[0];
252 255
 
253 256
 		$comma = ',';
@@ -294,8 +297,7 @@  discard block
 block discarded – undo
294 297
 			{
295 298
 				$groupSize1 = $decimalPos - $groupPos1 - 1;
296 299
 
297
-			}
298
-			else
300
+			} else
299 301
 			{
300 302
 				//no decimal point, so traverse from the back
301 303
 				//to find the groupsize 1.
@@ -310,15 +312,18 @@  discard block
 block discarded – undo
310 312
 			}
311 313
 
312 314
 			//get the second group size
313
-			if(is_int($groupPos2))
314
-				$groupSize2 = $groupPos1 - $groupPos2 - 1;
315
+			if(is_int($groupPos2)) {
316
+							$groupSize2 = $groupPos1 - $groupPos2 - 1;
317
+			}
315 318
 		}
316 319
 
317 320
 		if(is_int($decimalPos))
318 321
 		{
319 322
 			for($i = strlen($pattern) - 1; $i >= 0; $i--)
320 323
 			{
321
-				if($pattern{$i} == $dot) break;
324
+				if($pattern{$i} == $dot) {
325
+					break;
326
+				}
322 327
 				if($pattern{$i} == $digit)
323 328
 				{
324 329
 					$decimalPoints = $i - $decimalPos;
@@ -327,10 +332,11 @@  discard block
 block discarded – undo
327 332
 			}
328 333
 		}
329 334
 
330
-		if(is_int($decimalPos))
331
-			$digitPattern = substr($pattern, 0, $decimalPos);
332
-		else
333
-			$digitPattern = $pattern;
335
+		if(is_int($decimalPos)) {
336
+					$digitPattern = substr($pattern, 0, $decimalPos);
337
+		} else {
338
+					$digitPattern = $pattern;
339
+		}
334 340
 
335 341
 		$digitPattern = preg_replace('/[^0]/', '', $digitPattern);
336 342
 
@@ -507,10 +513,11 @@  discard block
 block discarded – undo
507 513
 	 */
508 514
 	public function getCurrencySymbol($currency = 'USD')
509 515
 	{
510
-		if(isset($this->pattern['symbol']))
511
-			return $this->pattern['symbol'];
512
-		else
513
-			return $this->data['Currencies'][$currency][0];
516
+		if(isset($this->pattern['symbol'])) {
517
+					return $this->pattern['symbol'];
518
+		} else {
519
+					return $this->data['Currencies'][$currency][0];
520
+		}
514 521
 	}
515 522
 
516 523
 
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_XLIFF.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function __construct($source)
60 60
 	{
61
-		$this->source = (string)$source;
61
+		$this->source = (string) $source;
62 62
 	}
63 63
 
64 64
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	protected function &loadData($filename)
70 70
 	{
71 71
 		//load it.
72
-		if(false === ($XML = simplexml_load_file($filename))) {
72
+		if (false === ($XML = simplexml_load_file($filename))) {
73 73
 			return false;
74 74
 		}
75 75
 
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
 
78 78
 		$translations = [];
79 79
 
80
-		foreach($translationUnit as $unit)
80
+		foreach ($translationUnit as $unit)
81 81
 		{
82
-			$source = (string)$unit->source;
83
-			$translations[$source][] = (string)$unit->target;
84
-			$translations[$source][] = (string)$unit['id'];
85
-			$translations[$source][] = (string)$unit->note;
82
+			$source = (string) $unit->source;
83
+			$translations[$source][] = (string) $unit->target;
84
+			$translations[$source][] = (string) $unit['id'];
85
+			$translations[$source][] = (string) $unit->note;
86 86
 		}
87 87
 
88 88
 		return $translations;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	protected function getSource($variant)
109 109
 	{
110
-		return $this->source . '/' . $variant;
110
+		return $this->source.'/'.$variant;
111 111
 	}
112 112
 
113 113
 	/**
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 	protected function getCatalogueList($catalogue)
129 129
 	{
130 130
 		$variants = explode('_', $this->culture);
131
-		$source = $catalogue . $this->dataExt;
131
+		$source = $catalogue.$this->dataExt;
132 132
 		$catalogues = [$source];
133 133
 		$variant = null;
134 134
 
135
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
135
+		for ($i = 0, $k = count($variants); $i < $k; ++$i)
136 136
 		{
137
-			if(isset($variants[$i]{0}))
137
+			if (isset($variants[$i]{0}))
138 138
 			{
139
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
140
-				$catalogues[] = $catalogue . $this->dataSeparator . $variant . $this->dataExt;
139
+				$variant .= ($variant) ? '_'.$variants[$i] : $variants[$i];
140
+				$catalogues[] = $catalogue.$this->dataSeparator.$variant.$this->dataExt;
141 141
 			}
142 142
 		}
143 143
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		$catalogues = array_merge($byDir, array_reverse($catalogues));
146 146
 		$files = [];
147 147
 
148
-		foreach($catalogues as $file)
148
+		foreach ($catalogues as $file)
149 149
 		{
150 150
 			$files[] = $file;
151 151
 			$files[] = preg_replace('/\.xml$/', '.xlf', $file);
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
 		$catalogues = [];
168 168
 		$variant = null;
169 169
 
170
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
170
+		for ($i = 0, $k = count($variants); $i < $k; ++$i)
171 171
 		{
172
-			if(isset($variants[$i]{0}))
172
+			if (isset($variants[$i]{0}))
173 173
 			{
174
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
175
-				$catalogues[] = $variant . '/' . $catalogue . $this->dataExt;
174
+				$variant .= ($variant) ? '_'.$variants[$i] : $variants[$i];
175
+				$catalogues[] = $variant.'/'.$catalogue.$this->dataExt;
176 176
 			}
177 177
 		}
178 178
 
@@ -198,28 +198,28 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	protected function getCatalogues($dir = null, $variant = null)
200 200
 	{
201
-		$dir = $dir?$dir:$this->source;
201
+		$dir = $dir ? $dir : $this->source;
202 202
 		$files = scandir($dir);
203 203
 		$catalogue = [];
204 204
 
205
-		foreach($files as $file)
205
+		foreach ($files as $file)
206 206
 		{
207
-			if(is_dir($dir . '/' . $file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file)) {
207
+			if (is_dir($dir.'/'.$file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file)) {
208 208
 				$catalogue = array_merge(
209 209
 					$catalogue,
210
-					$this->getCatalogues($dir . '/' . $file, $file)
210
+					$this->getCatalogues($dir.'/'.$file, $file)
211 211
 				);
212 212
 			}
213 213
 
214 214
 			$pos = strpos($file, $this->dataExt);
215
-			if($pos > 0 && substr($file, -1 * strlen($this->dataExt)) == $this->dataExt)
215
+			if ($pos > 0 && substr($file, -1 * strlen($this->dataExt)) == $this->dataExt)
216 216
 			{
217 217
 				$name = substr($file, 0, $pos);
218 218
 				$dot = strrpos($name, $this->dataSeparator);
219 219
 				$culture = $variant;
220 220
 				$cat = $name;
221 221
 
222
-				if(is_int($dot))
222
+				if (is_int($dot))
223 223
 				{
224 224
 					$culture = substr($name, $dot + 1, strlen($name));
225 225
 					$cat = substr($name, 0, $dot);
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	private function getVariants($catalogue = 'messages')
246 246
 	{
247
-		if($catalogue === null) {
247
+		if ($catalogue === null) {
248 248
 			$catalogue = 'messages';
249 249
 		}
250 250
 
251
-		foreach($this->getCatalogueList($catalogue) as $variant)
251
+		foreach ($this->getCatalogueList($catalogue) as $variant)
252 252
 		{
253 253
 			$file = $this->getSource($variant);
254
-			if(is_file($file)) {
254
+			if (is_file($file)) {
255 255
 				return [$variant, $file];
256 256
 			}
257 257
 		}
@@ -268,19 +268,19 @@  discard block
 block discarded – undo
268 268
 	public function save($catalogue = 'messages')
269 269
 	{
270 270
 		$messages = $this->untranslated;
271
-		if(count($messages) <= 0) {
271
+		if (count($messages) <= 0) {
272 272
 			return false;
273 273
 		}
274 274
 
275 275
 		$variants = $this->getVariants($catalogue);
276 276
 
277
-		if($variants) {
277
+		if ($variants) {
278 278
 			list($variant, $filename) = $variants;
279 279
 		} else {
280 280
 			list($variant, $filename) = $this->createMessageTemplate($catalogue);
281 281
 		}
282 282
 
283
-		if(is_writable($filename) == false) {
283
+		if (is_writable($filename) == false) {
284 284
 			throw new TIOException("Unable to save to file {$filename}, file must be writable.");
285 285
 		}
286 286
 
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
 		$body = $xpath->query('//body')->item(0);
294 294
 
295 295
 		$lastNodes = $xpath->query('//trans-unit[last()]');
296
-		if(($last = $lastNodes->item(0)) !== null) {
297
-			$count = (int)$last->getAttribute('id');
296
+		if (($last = $lastNodes->item(0)) !== null) {
297
+			$count = (int) $last->getAttribute('id');
298 298
 		} else {
299 299
 			$count = 0;
300 300
 		}
301 301
 
302 302
 		//for each message add it to the XML file using DOM
303
-		foreach($messages as $message)
303
+		foreach ($messages as $message)
304 304
 		{
305 305
 			$unit = $dom->createElement('trans-unit');
306 306
 			$unit->setAttribute('id', ++$count);
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 
329 329
 		//save it and clear the cache for this variant
330 330
 		$dom->save($filename);
331
-		if(!empty($this->cache)) {
331
+		if (!empty($this->cache)) {
332 332
 			$this->cache->clean($variant, $this->culture);
333 333
 		}
334 334
 
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 	{
348 348
 		$variants = $this->getVariants($catalogue);
349 349
 
350
-		if($variants) {
350
+		if ($variants) {
351 351
 			list($variant, $filename) = $variants;
352 352
 		} else {
353 353
 			return false;
354 354
 		}
355 355
 
356
-		if(is_writable($filename) == false) {
356
+		if (is_writable($filename) == false) {
357 357
 			throw new TIOException("Unable to update file {$filename}, file must be writable.");
358 358
 		}
359 359
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 		$units = $xpath->query('//trans-unit');
366 366
 
367 367
 		//for each of the existin units
368
-		foreach($units as $unit)
368
+		foreach ($units as $unit)
369 369
 		{
370 370
 			$found = false;
371 371
 			$targetted = false;
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 
374 374
 			//in each unit, need to find the source, target and comment nodes
375 375
 			//it will assume that the source is before the target.
376
-			foreach($unit->childNodes as $node)
376
+			foreach ($unit->childNodes as $node)
377 377
 			{
378 378
 				//source node
379
-				if($node->nodeName == 'source' && $node->firstChild->wholeText == $text) {
379
+				if ($node->nodeName == 'source' && $node->firstChild->wholeText == $text) {
380 380
 					$found = true;
381 381
 				}
382 382
 
383 383
 				//found source, get the target and notes
384
-				if($found)
384
+				if ($found)
385 385
 				{
386 386
 					//set the new translated string
387
-					if($node->nodeName == 'target')
387
+					if ($node->nodeName == 'target')
388 388
 					{
389 389
 						$node->nodeValue = $target;
390 390
 						$targetted = true;
391 391
 					}
392 392
 
393 393
 					//set the notes
394
-					if(!empty($comments) && $node->nodeName == 'note')
394
+					if (!empty($comments) && $node->nodeName == 'note')
395 395
 					{
396 396
 						$node->nodeValue = $comments;
397 397
 						$commented = true;
@@ -400,17 +400,17 @@  discard block
 block discarded – undo
400 400
 			}
401 401
 
402 402
 			//append a target
403
-			if($found && !$targetted) {
403
+			if ($found && !$targetted) {
404 404
 				$unit->appendChild($dom->createElement('target', $target));
405 405
 			}
406 406
 
407 407
 			//append a note
408
-			if($found && !$commented && !empty($comments)) {
408
+			if ($found && !$commented && !empty($comments)) {
409 409
 				$unit->appendChild($dom->createElement('note', $comments));
410 410
 			}
411 411
 
412 412
 			//finished searching
413
-			if($found) {
413
+			if ($found) {
414 414
 				break;
415 415
 			}
416 416
 		}
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 		$fileNode = $xpath->query('//file')->item(0);
419 419
 		$fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z'));
420 420
 
421
-		if($dom->save($filename) > 0)
421
+		if ($dom->save($filename) > 0)
422 422
 		{
423
-			if(!empty($this->cache)) {
423
+			if (!empty($this->cache)) {
424 424
 				$this->cache->clean($variant, $this->culture);
425 425
 			}
426 426
 
@@ -439,13 +439,13 @@  discard block
 block discarded – undo
439 439
 	public function delete($message, $catalogue = 'messages')
440 440
 	{
441 441
 		$variants = $this->getVariants($catalogue);
442
-		if($variants) {
442
+		if ($variants) {
443 443
 			list($variant, $filename) = $variants;
444 444
 		} else {
445 445
 			return false;
446 446
 		}
447 447
 
448
-		if(is_writable($filename) == false) {
448
+		if (is_writable($filename) == false) {
449 449
 			throw new TIOException("Unable to modify file {$filename}, file must be writable.");
450 450
 		}
451 451
 
@@ -457,22 +457,22 @@  discard block
 block discarded – undo
457 457
 		$units = $xpath->query('//trans-unit');
458 458
 
459 459
 		//for each of the existin units
460
-		foreach($units as $unit)
460
+		foreach ($units as $unit)
461 461
 		{
462 462
 			//in each unit, need to find the source, target and comment nodes
463 463
 			//it will assume that the source is before the target.
464
-			foreach($unit->childNodes as $node)
464
+			foreach ($unit->childNodes as $node)
465 465
 			{
466 466
 				//source node
467
-				if($node->nodeName == 'source' && $node->firstChild->wholeText == $message)
467
+				if ($node->nodeName == 'source' && $node->firstChild->wholeText == $message)
468 468
 				{
469 469
 					//we found it, remove and save the xml file.
470 470
 					$unit->parentNode->removeChild($unit);
471 471
 					$fileNode = $xpath->query('//file')->item(0);
472 472
 					$fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z'));
473 473
 
474
-					if(false !== $dom->save($filename)) {
475
-						if(!empty($this->cache)) {
474
+					if (false !== $dom->save($filename)) {
475
+						if (!empty($this->cache)) {
476 476
 							$this->cache->clean($variant, $this->culture);
477 477
 						}
478 478
 						return true;
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 
489 489
 	protected function createMessageTemplate($catalogue)
490 490
 	{
491
-		if($catalogue === null) {
491
+		if ($catalogue === null) {
492 492
 			$catalogue = 'messages';
493 493
 		}
494 494
 		
@@ -497,12 +497,12 @@  discard block
 block discarded – undo
497 497
 		$file = $this->getSource($variant);
498 498
 		$dir = dirname($file);
499 499
 
500
-		if(!is_dir($dir)) {
500
+		if (!is_dir($dir)) {
501 501
 			@mkdir($dir);
502 502
 			@chmod($dir, PRADO_CHMOD);
503 503
 		}
504 504
 
505
-		if(!is_dir($dir)) {
505
+		if (!is_dir($dir)) {
506 506
 			throw new TException("Unable to create directory $dir");
507 507
 		}
508 508
 		
Please login to merge, or discard this patch.