-
Notifications
You must be signed in to change notification settings - Fork 81
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
Refactoring Suggestion - Remove Format from Writer Class #3
Comments
A IMHO simpler approach would be to use a derived class for each type of feed: class RSS2FeedWriter extends FeedWriter
{
function __construct()
{
parent::__construct(RSS2);
}
} Important would be to change the visibility of the constructor of the FeedWriter class to I've just tested this, and it works flawlessly. The only change is to create an |
Hey up, yeah I'd go with that, but u might want to consider extracting the responsibilities out of the super class ;) though that would be quite a big job & I don't think it'd be worth anyone's time doing that refactoring yet. Maybe if more feed formats start to take over RSS and atom, maybe then ;) |
Oh might also want to set the super class to abstract - since u can't instantiate the class without extending it :) though setting the class to abstract and the constructor to protected would break backward compatibility.... Meaning maybe hold that back until the next major release? |
Yes, I have the same opinion: The base class should be independent from any feed type and offering just functions for the core XML stuff. Are there some new feed types on the horizon? Since this is a relatively small project I never thought about "real" releases - HEAD should always work... |
Might be worth while just creating a quick branch for version 2 that includes the proper refactoring - if you got the time that is. At the end of the day the code that's there now works perfectly fine so it's really not a big problem :) Regarding the feed types... thinking more of custom feeds or internal syndication feeds such as a private feed format specialised for providing transcripts for podcasts where the internal readers can understand them but public ones wouldn't. Since you have called it the "Universal" feed writer ;) P.S. Whens the Universal Feed Reader coming? Complete set then! |
- PHP>=8.1 trigger deprecation error with no manner code. - `preg_replace(): Passing null to parameter mibe#3 ($subject) of type array|string is deprecated`
- PHP>=8.1 trigger deprecation error with no manner code. - `preg_replace(): Passing null to parameter mibe#3 ($subject) of type array|string is deprecated`
- PHP>=8.1 trigger deprecation error with no manner code. - `preg_replace(): Passing null to parameter mibe#3 ($subject) of type array|string is deprecated`
- PHP>=8.1 trigger deprecation error with no manner code. - `preg_replace(): Passing null to parameter mibe#3 ($subject) of type array|string is deprecated`
Just expanding on the previous patch. A better idea would be to remove the responsibility of the writer class having to valid the format is valid. So in the class below i have removed that responsibility to a new format class, which can then make use of type hinting to enforce the correct type is given to the constructor of the writer class.
Not tested this code and it's almost 1am for me, but it's just to show you a rough idea of how it would work and how it would make adding new formats a little easier in the future. Hope it helps or at least gives you more ideas.
Just a thought.
Kind regards,
Scott
The text was updated successfully, but these errors were encountered: