次の 2 つのクラスの場合:
配列をパラメーターとして使用するか、1 つずつ使用する必要がありますか?
class image {
public function __construct(array $color, array $padding) {
...
}
}
class image {
public function __construct($red, $green, $blue, $paddingtop, $paddingright, $paddingbottom, $paddingleft) {
...
}
}
クラス プロパティの場合:
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' => ...);
}
それらを配列または単一の変数として扱う方が良いですか?
たぶん、この質問には決まった答えがないかもしれませんが、私はPHPの初心者であり、実務経験がありません。どの方法が最も一般的であるか、他のコーダーが読みやすいかについての提案を聞きたいです.
ありがとう!