servo-php / fluidxml

FluidXML, the PHP library for manipulating XML with a concise and fluent API.
BSD 2-Clause "Simplified" License
458 stars 45 forks source link

'getText' method #26

Closed alepeino closed 7 years ago

alepeino commented 7 years ago

Added ->getText() that returns the text content of nodes in a context. Also short version as ->text() (no parameter). --> What do you think of PHP_EOL as default? Maybe ',' better? Or '' ?

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 99.818% when pulling ec17a3e223e8675dec856508eabd848e468e801a on alepeino:gettext-method into b6fb8de6ff781479c9e4fb6e9f27b5af1e87dc4b on servo-php:master.

daniele-orlando commented 7 years ago

Hi dear @alepeino and thank you again for your appreciated PLs.

FluidXML is a library mainly intended for manipulating XML files. As you can see from the API, it is made by methods used to mutate the document or to export it. Reading the internal state of the document is not a goal for the 1.x release but it will probably change in the 2.x release implementing a reading-specific API style.

Unfortunately implementing the ->text() getter method would break the coherence of the API mainly duplicating features already implemented in the native DOM API.

Even if your effort in this PL is very much appreciated, I can not accept it at least for the 1.x releases. It will be probably part of the 2th main release of FluidXML, but for now I can not merge it.

Thank you very much again for you effort.

alepeino commented 7 years ago

Yes, I understand what you mean. In my current project I'm reading/parsing XMLs as much as I am writing/manipulating them. That's how I thought of these features I have sent, since I thought the reading-specific part could also benefit from a fluid, elegant and convenient API. I'll wait for v2, to which I will try to contribute as well.