So I've decided to put several disparate but related functions into helper classes. Here's an example of what such a class would look like (with obviously more involved methods), and I'd like a critique on it's structure.
class MyHelpers {
public $str;
public $Array;
private $Params;
public function __construct($method, $Params) {
$method = '_' . $method;
$this->Params = (is_array($Params)) ? $Params : NULL;
$result = (method_exists($this, $method)) ? $this->$method() : NULL;
(is_array($result)) ? $this->Array = $result : $this->str = $result;
}
private function _outputString() {
if(is_array($this->Params)) :
$str = (isset($this->Params['str'])) ? $this->Params['str'] : NULL;
return $str;
endif;
}
private function _makeArray() {
if(is_array($this->Params)) :
$str = (isset($this->Params['array'])) ? $this->Params['array'] : NULL;
$Array = explode(',', $str);
return $Array;
endif;
}
}
And here's how you would instantiate and use it:
$GetResult = new MyHelpers('outputString', array('str'=>'This is a string.'));
$str = $GetResult->str;
$GetResult = new MyHelpers('makeArray', array('array'=>'1,2,3'));
$Array = $GetResult->Array;
Thoughts?