Jump to content

Object Oriented PHP question


soulmedia

Recommended Posts

Hi,

 

I have a class that I've written to make a basic PDF report. I want to add the ability to create graphs in these reports, and was wondering about the best way to do it, design-wise.

 

I though it would be good to maybe extend my original class, but for when each graph has been completed, I would need a way of 'cleaning' the extended class of the data I have set, without affecting the base class.

 

My other thought was to create the class 'standalone' and then pass a reference to the PDF object to it, so that I can use the base class's methods and properties. This would mean I could unset() and create a new instance for each graph, so not have to worry about cleaning up. But the disadvantage is that I would have to make much of the base class 'public' in order to get the access that I need.

 

Or should I put the extra code straight into the base class?

 

Many thanks in advance for your advice..

 

Peter

Link to comment
https://forums.phpfreaks.com/topic/142552-object-oriented-php-question/
Share on other sites

Many thanks for your reply.

 

I would like to be able to do it that way; the problem is I am generating the graphs directly into the PDF rather than as a graphic.

I will look into changing to GD, or similar, as it would be a simpler way of doing things. The ability to write the graphs as PDF information did appeal to me though, mainly because of the reduced file sizes in comparison to including graphics.

 

Thanks again,

 

Peter

redarrow: Thanks for your recommendation. The reason I chose to write my own code is that the graph I need to produce is very specialised. I have tried libraries such as JPGraph and found that they wouldn't do what I wanted without further modification, so decided to write my own.

 

cooldude832: I'm using PDFlib; I have written a wrapper class to hide some of the complexities and make report writing quicker. I create the PDF document and instantiate the PDFlib object in the wrapper class.

Hi,

 

I decided to go for the 'extend the base class' approach. To get around the 'cleaning up' issue I am using the reflectionClass object to enumerate the properties of the current object and nullify only those variables with a clean() method.

 

Thanks for all your suggestions.

 

Peter

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.