@@ -116,7 +116,7 @@ public function getFormatOutput()
116
116
public function setCustomRootName ($ value )
117
117
{
118
118
if (!$ this ->isValidXmlTag ($ value )) {
119
- throw new \Exception ('Not a valid root name: ' . $ value );
119
+ throw new \Exception ('Not a valid root name: ' . $ value );
120
120
}
121
121
122
122
$ this ->_custom_root_name = $ value ;
@@ -154,7 +154,7 @@ public function getDefaultRootName()
154
154
public function setCustomTagName ($ value )
155
155
{
156
156
if (!$ this ->isValidXmlTag ($ value )) {
157
- throw new \Exception ('Not a valid tag name: ' . $ value );
157
+ throw new \Exception ('Not a valid tag name: ' . $ value );
158
158
}
159
159
160
160
$ this ->_custom_tag_name = $ value ;
@@ -217,14 +217,14 @@ public function getSeparator()
217
217
*/
218
218
public function setTransformTags ($ value = null )
219
219
{
220
- switch ($ value ) {
220
+ switch ($ value ) {
221
221
case self ::LOWERCASE :
222
222
case self ::UPPERCASE : {
223
223
$ this ->_transform_tags = $ value ;
224
224
break ;
225
225
}
226
226
default : {
227
- if ($ value === null ) {
227
+ if ($ value === null ) {
228
228
$ this ->_transform_tags = null ;
229
229
}
230
230
}
@@ -253,7 +253,7 @@ public function setNumericTagSuffix($value = null)
253
253
{
254
254
$ this ->_numeric_tag_suffix = $ value ;
255
255
256
- if ($ value === true || $ value === false ) {
256
+ if ($ value === true || $ value === false ) {
257
257
$ this ->_numeric_tag_suffix = '' ;
258
258
}
259
259
return $ this ;
@@ -340,7 +340,7 @@ public function getCastNullValue()
340
340
*/
341
341
public static function hasValidXmlTagStartingChar ($ value = null )
342
342
{
343
- if (preg_match (self ::getValidXmlTagStartPattern (), $ value ) === 1 ) {
343
+ if (preg_match (self ::getValidXmlTagStartPattern (), $ value ) === 1 ) {
344
344
return true ;
345
345
}
346
346
return false ;
@@ -354,7 +354,7 @@ public static function hasValidXmlTagStartingChar($value = null)
354
354
*/
355
355
public static function isValidXmlTagChar ($ value = null )
356
356
{
357
- if (preg_match (self ::getValidXmlTagNameChar (), $ value ) === 1 ) {
357
+ if (preg_match (self ::getValidXmlTagNameChar (), $ value ) === 1 ) {
358
358
return true ;
359
359
}
360
360
return false ;
@@ -368,11 +368,11 @@ public static function isValidXmlTagChar($value = null)
368
368
*/
369
369
public static function isValidXmlTag ($ value = null )
370
370
{
371
- if (empty ($ value ) || is_int ($ value )) {
371
+ if (empty ($ value ) || is_int ($ value )) {
372
372
return false ;
373
373
}
374
374
375
- if (preg_match (self ::getValidXmlTagNamePattern (), $ value ) === 1 ) {
375
+ if (preg_match (self ::getValidXmlTagNamePattern (), $ value ) === 1 ) {
376
376
return true ;
377
377
}
378
378
return false ;
@@ -458,19 +458,19 @@ protected function addArrayElements(DOMElement $parent, $array = [])
458
458
$ parent ->appendChild ($ node );
459
459
} else {
460
460
461
- if (array_key_exists ('@value ' , $ value )) {
461
+ if (array_key_exists ('@value ' , $ value )) {
462
462
$ cdata = array_key_exists ('@cdata ' , $ value ) && $ value ['@cdata ' ] === true ? true : false ;
463
463
$ attributes = array_key_exists ('@attr ' , $ value ) && is_array ($ value ['@attr ' ]) ? $ value ['@attr ' ] : [];
464
464
465
- if (!is_array ($ value ['@value ' ])) {
465
+ if (!is_array ($ value ['@value ' ])) {
466
466
// Create an XML element
467
467
$ node = $ this ->createElement ($ name , $ value ['@value ' ], $ cdata , $ attributes );
468
468
$ parent ->appendChild ($ node );
469
469
} else {
470
470
// Create an empty XML element 'container'
471
471
$ node = $ this ->createElement ($ name , null );
472
472
473
- foreach ($ attributes as $ attribute_name => $ attribute_value ) {
473
+ foreach ($ attributes as $ attribute_name => $ attribute_value ) {
474
474
$ node ->setAttribute ($ attribute_name , $ this ->normalizeAttributeValue ($ attribute_value ));
475
475
}
476
476
@@ -479,8 +479,7 @@ protected function addArrayElements(DOMElement $parent, $array = [])
479
479
// Add all the elements within the array to the 'container'
480
480
$ this ->addArrayElements ($ node , $ value ['@value ' ]);
481
481
}
482
- }
483
- else {
482
+ } else {
484
483
// Create an empty XML element 'container'
485
484
$ node = $ this ->createElement ($ name , null );
486
485
$ parent ->appendChild ($ node );
@@ -501,15 +500,15 @@ protected function addArrayElements(DOMElement $parent, $array = [])
501
500
*/
502
501
protected function normalizeValue ($ value )
503
502
{
504
- if ($ value === true ) {
503
+ if ($ value === true ) {
505
504
return $ this ->getCastBooleanValueTrue ();
506
505
}
507
506
508
- if ($ value === false ) {
507
+ if ($ value === false ) {
509
508
return $ this ->getCastBooleanValueFalse ();
510
509
}
511
510
512
- if ($ value === null ) {
511
+ if ($ value === null ) {
513
512
return $ this ->getCastNullValue ();
514
513
}
515
514
@@ -524,11 +523,11 @@ protected function normalizeValue($value)
524
523
*/
525
524
protected function normalizeAttributeValue ($ value )
526
525
{
527
- if ($ value === true ) {
526
+ if ($ value === true ) {
528
527
return 'true ' ;
529
528
}
530
529
531
- if ($ value === false ) {
530
+ if ($ value === false ) {
532
531
return 'false ' ;
533
532
}
534
533
@@ -561,11 +560,11 @@ protected function createElement($name, $value = null, $cdata = false, $attribut
561
560
{
562
561
$ name = $ this ->createValidTagName ($ name );
563
562
564
- if ($ cdata === true ) {
563
+ if ($ cdata === true ) {
565
564
$ element = $ this ->_doc ->createElement ($ name );
566
565
$ element ->appendChild ($ this ->_doc ->createCDATASection ($ value ));
567
566
568
- foreach ($ attributes as $ attribute_name => $ attribute_value ) {
567
+ foreach ($ attributes as $ attribute_name => $ attribute_value ) {
569
568
$ element ->setAttribute ($ attribute_name , $ this ->normalizeAttributeValue ($ attribute_value ));
570
569
}
571
570
@@ -574,7 +573,7 @@ protected function createElement($name, $value = null, $cdata = false, $attribut
574
573
575
574
$ element = $ this ->_doc ->createElement ($ name , $ this ->normalizeValue ($ value ));
576
575
577
- foreach ($ attributes as $ attribute_name => $ attribute_value ) {
576
+ foreach ($ attributes as $ attribute_name => $ attribute_value ) {
578
577
$ element ->setAttribute ($ attribute_name , $ this ->normalizeAttributeValue ($ attribute_value ));
579
578
}
580
579
@@ -589,7 +588,7 @@ protected function createElement($name, $value = null, $cdata = false, $attribut
589
588
*/
590
589
protected function createValidTagName ($ name = null )
591
590
{
592
- if (empty ($ name ) || $ this ->isNumericKey ($ name )) {
591
+ if (empty ($ name ) || $ this ->isNumericKey ($ name )) {
593
592
$ key = $ name ;
594
593
595
594
if ($ this ->isValidXmlTag ($ this ->getCustomTagName ())) {
@@ -598,16 +597,16 @@ protected function createValidTagName($name = null)
598
597
$ name = $ this ->transformTagName ($ this ->getDefaultTagName ());
599
598
}
600
599
601
- if ($ this ->getNumericTagSuffix () !== null ) {
602
- $ name = $ name . (string )$ this ->getNumericTagSuffix () . $ key ;
600
+ if ($ this ->getNumericTagSuffix () !== null ) {
601
+ $ name = $ name. (string ) $ this ->getNumericTagSuffix (). $ key ;
603
602
}
604
603
return $ name ;
605
604
}
606
605
607
- if (!$ this ->isValidXmlTag ($ name )) {
606
+ if (!$ this ->isValidXmlTag ($ name )) {
608
607
$ name = $ this ->replaceInvalidTagChars ($ name );
609
608
610
- if (!self ::hasValidXmlTagStartingChar ($ name )) {
609
+ if (!self ::hasValidXmlTagStartingChar ($ name )) {
611
610
$ name = $ this ->prefixInvalidTagStartingChar ($ name );
612
611
}
613
612
}
@@ -622,7 +621,7 @@ protected function createValidTagName($name = null)
622
621
*/
623
622
protected function prefixInvalidTagStartingChar ($ value )
624
623
{
625
- return '_ ' . substr ($ value , 1 );
624
+ return '_ ' . substr ($ value , 1 );
626
625
}
627
626
628
627
/**
@@ -634,13 +633,13 @@ protected function prefixInvalidTagStartingChar($value)
634
633
protected function replaceInvalidTagChars ($ value )
635
634
{
636
635
$ pattern = '' ;
637
- for ($ i= 0 ; $ i < strlen ($ value ); $ i ++) {
638
- if (!self ::isValidXmlTagChar ($ value [$ i ])) {
636
+ for ($ i = 0 ; $ i < strlen ($ value ); $ i ++) {
637
+ if (!self ::isValidXmlTagChar ($ value [$ i ])) {
639
638
$ pattern .= "\\$ value [$ i ]" ;
640
639
}
641
640
}
642
641
643
- if (!empty ($ pattern )) {
642
+ if (!empty ($ pattern )) {
644
643
$ value = preg_replace ("/[ {$ pattern }]/ " , $ this ->getSeparator (), $ value );
645
644
}
646
645
return $ value ;
@@ -671,7 +670,7 @@ protected function createValidRootName($name = null)
671
670
*/
672
671
protected function transformTagName ($ name = null )
673
672
{
674
- switch ($ this ->getTransformTags ()) {
673
+ switch ($ this ->getTransformTags ()) {
675
674
case self ::LOWERCASE : {
676
675
return strtolower ($ name );
677
676
}
0 commit comments