Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow white space for json simple xml element decorator #12

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

shawkiIIalasy
Copy link

@shawkiIIalasy shawkiIIalasy commented Jul 5, 2022

Add flexibility for allowing white spaces when elements have white space

Current behaviour:

    $xml = `<document><alias> Name</alias></document>`
    
    $arr = LaravelXml::decode('<document><alias> Name</alias></document>', 'SimpleXMLElement', 0, '', false);

    echo $arr['alias']; // `Name`
    so the decoded value of the alias will be `Name` without white space because the package will always trim the subject

Desired behaviour

    $xml = `<document><alias> Name</alias></document>`
    
     // Trim Whitespace (Not allow whitespace)
    $arr = LaravelXml::decode('<document><alias> Name</alias></document>', 'SimpleXMLElement', 0, '', false, false);
    echo $arr['alias']; // ` Name`


    // Allow  Whitespace
    $arr = LaravelXml::decode('<document><alias> Name</alias></document>', 'SimpleXMLElement', 0, '', false, true);
    echo $arr['alias']; // ` Name`


    so the decoded value of the alias will be `Name` without white space by default but if you set allow whitespace true then the alias will be ` Name` with whitespace 

Case

We compare an encrypted XML request from third parties with our request but because the encrypted request was encrypted with whitespace will not match our request, generally, we don't want to edit any value of the XML request

@mtvbrianking
Copy link
Owner

Hi @shawkiIIalasy,

Thanks for the contribution. It would be nice of you to add a detailed description of what this pull request solves or improves

Code snippet comparisons of the current package behavior vs your desired behavior would make a great illustration.

@mtvbrianking
Copy link
Owner

@shawkiIIalasy I've added a commit to test allowing significant white space in indented xml

@shawkiIIalasy
Copy link
Author

@mtvbrianking

Hi @shawkiIIalasy,

Thanks for the contribution. It would be nice of you to add a detailed description of what this pull request solves or improves

Code snippet comparisons of the current package behavior vs your desired behavior would make a great illustration.

Description Added, Please check

@shawkiIIalasy
Copy link
Author

@mtvbrianking please check

@shawkiAlasy
Copy link

shawkiAlasy commented Jun 13, 2023

@mtvbrianking Can you check?

@mtvbrianking
Copy link
Owner

Hi @shawkiAlasy

The unit tests are still failing

@shawkiIIalasy
Copy link
Author

@mtvbrianking Tests: passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants