For the following two classes:
should I use array as a parameter or one by one?
class image {
public function __construct(array $color, array $padding) {
...
}
}
class image {
public function __construct($red, $green, $blue, $paddingtop, $paddingright, $paddingbottom, $paddingleft) {
...
}
}
Also for class properties:
class image {
protected $paddingtop;
protected $paddingright;
protected $paddingbottom;
protected $paddingleft;
protected $colorred;
protected $colorgreen;
protected $colorblue;
}
class image {
protected $padding = array('top' => ..., 'right' => ..., 'bottom' => ..., 'left' => ...);
protected $color = array('red' => ..., 'green' => ..., 'blue' => ...);
}
Is it better to treat them as an array or a single variable?
Maybe this question don't have a fixed answer, but I'm just a php beginner and don't have any work experience, I wanna hear your suggestion which way is the most common use or easy for other coders to read.
Thanks!