I want function explicitSetX( $value){} to be public in a specific task otherwise it should be private. (functionality of private)
(Im not interested in how to write generic setters, this question is about Visibility / Accesibility)
class My_Object{
public function genericArrSetter ( $property, $value ){
$this->$property = $value;
}
}
class Obj extends My_Object{
private $x;
private $x1;
private $x2;
private $x3;
private $x4;
private $x5;
private $x6;
private $x7;
private $x8;
public function explicitSetX( $value){
$this->XX = $value;
}
}
/*
* Below functions run from outside
* I would like to force this behaviour since now
* its possible for others to use myStart. (way of setting)
*/
function myStart (){
// set all data in Obj via generic setter
$obj = new Obj();
$obj-> genericArrSetter("x","value for x");
}
function OtherStart (){
// set all data in Obj via explicit setter
$obj = new Obj();
$obj-> explicitSetX ("value for x");
}