php - To include methods in a model or not? -


I have a class that acts as a model for an image:

  class Image {public $ imageId; Public $ title; Public $ description; Public $ filename; Public $ enabled; Public $ galleryId; Public $ gallery name; Public $ order no; }   

I also have a class, ImageMapper which captures information about the image from DB and fills up image I'm not showing you the appropriate data because it is a very bad piece of code: -)

Here's an example of how I do this:

  $ image = new image (); $ Image- & gt; ImageId = $ previously received; $ ImageMapper = New ImageMapper (); $ Image = $ imageMapper-> Find ($ image- & gt; imageId);   

My question is: Where should I include ways to change information about the image? For example, the property of the $ enabled image class is displayed by 0 or 1 in the database. When I display that property on the page that is to be read by humans, then I will show it "no" or "yes" respectively. Should I include a function to translate the image class, the image of the image mapping class, on the page that shows the number to the user, or somewhere else?

I've heard that it's bad to include the functions in the data object, which I'm calling the image object.

Here is an example of this method I am referring to:

  public function getEnabledAsText () {if (! $ This-> enabled) {return 'No'; } Return 'yes'; }    

I was supposed to write a ImageDataPresenter class and Use the ugly image properties to "translate" into beautiful human readable texts.

  $ presenter = new ImageDataPresenter ($ imageobj); Echo $ Presenter- & gt; capable; // 'yes'    

Comments