Skip to content
Advertisement

PHP Methods and Class Design [closed]

Which design concept is better in PHP; passing variable to the function myFunct() or not passing the variable?

JavaScript

Here is maybe a better example of what I am trying to understand:

JavaScript

Advertisement

Answer

Generally keep at class scope variables describing your class and usually required by most of your “important”(methods tha also describe what the class can do or has) methods.

At first glance, in your case the method imageCreateFromFormat($srcImage,$fileImageTypeFlag) looks fine and self contained . But the method createThumb if all it does is what you posted then remove it along with the two class variables and rename the other method to createThumb.

If it is unfinished and after calling the method imageCreateFromFormat is going to crop the image and create a thumbnail, then there is no reason to have class scope variables you can remove them unless you plan to rename the class and add a bunch of methods that use these two variables.

Finally, care must be taken with class names, it is not good practice to use plural and the word class.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement