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

Added Cdata class to allow writing of CDATA values #21

Merged
merged 4 commits into from
Apr 7, 2019
Merged

Added Cdata class to allow writing of CDATA values #21

merged 4 commits into from
Apr 7, 2019

Conversation

zyura
Copy link
Contributor

@zyura zyura commented Apr 6, 2019

Sometimes it's desired to use CDATA in the resulting XML file instead of regular XML escaping.

Cdata wrapper class allows to achieve this:

$html_desc = '<p>Some HTML code</p>';
$offer = (new OfferSimple())
    ->setDescription(new Cdata($html_desc))

will result in

<description><![CDATA[<p>Some HTML code</p>]]></description>

instead of

<description>&lt;p&gt;Some HTML code&lt;/p&gt;</description>

@Bukashk0zzz
Copy link
Owner

Hi, Thank you for PR.

There are some code style problems https://travis-ci.org/Bukashk0zzz/YmlGenerator/jobs/516475287

Can you please fix them before I merge this?

@zyura
Copy link
Contributor Author

zyura commented Apr 6, 2019

Sure, I'll commit the fixed version soon.

@codecov-io
Copy link

codecov-io commented Apr 6, 2019

Codecov Report

Merging #21 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##             master    #21   +/-   ##
=======================================
  Coverage       100%   100%           
- Complexity      245    248    +3     
=======================================
  Files            17     18    +1     
  Lines           682    691    +9     
=======================================
+ Hits            682    691    +9
Impacted Files Coverage Δ Complexity Δ
src/Generator.php 100% <100%> (ø) 47 <0> (+1) ⬆️
src/Cdata.php 100% <100%> (ø) 2 <2> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ae4bd9...8429427. Read the comment docs.

Yurij Zagrebnoy added 2 commits April 6, 2019 22:49
Changed AbstrcactGeneratorTest::createOffers() visibility from private
to protected in order to allow overriding it because it sets the
description overriding value set in the createOffer()
Moved AbstractGeneratorTest::createOffers() to be located above private
methods; added doc comments to OfferCdataGeneratorTest
@zyura
Copy link
Contributor Author

zyura commented Apr 6, 2019

Fixed all code style issues, added a test for the Cdata class: OfferCdataGeneratorTest.
Had to raise method visibility of AbstractGeneratorTest::createOffers() to protected because it didn't allow to define custom offer description: description set in overridden createOffer() was overwritten by

    ->setDescription($this->faker->sentence)

@Bukashk0zzz Bukashk0zzz merged commit 3df790d into Bukashk0zzz:master Apr 7, 2019
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