Completed
Push — master ( a7894a...d2af4c )
by Thiago Augustus de
02:08
created

NoXMLSpace.class.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * NoXMLSpace
5
 * 
6
 * @author Thiago Augustus de Oliveira
7
 * @version 1.0.0
8
 * @copyright MIT Copyright (c) 2015
9
 */
10
final class NoXMLSpace
11
{
12
13
	/**
14
	 * noSpace
15
	 * Remove all spaces in both side of the words in a .xml file
16
	 *
17
	 * Here is an inline example:
18
	 * <code>
19
	 *   <?php
20
	 *     $file = simplexml_load_file($_FILES['xml']['tmp_name']);
21
	 *     $xml  = noSpace($xml);
22
	 *   ?>
23
	 * </code>
24
	 *
25
	 * @param xml
26
	 * @return xml
27
	 * @access public
28
	 */
29
	public static function noSpace( $xml = null )
30
	{
31
32
		if ( empty( $xml ) || is_null( $xml ) ) return false;
33
34 View Code Duplication
		foreach ( $xml as $key => $value ) {
35
			if ( sizeof( $value ) > 1 ) {
36
				noSpace( $value ); // Get next node
37
			} else {
38
				$xml->$key = trim( $value );
39
			}
40
		}
41
		return $xml;
42
	}
43
44
}
45
46
// $xml = simplexml_load_file( $xml_file );
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
47
// Example: var_dump( '<pre>', NoXMLSpace::noSpace($xml) );
48