I am new to OOP and am wondering what is the right way to OOP. My class has a method getValueto which the input (key) is passed, which it uses to search for an array and returns a value.
The thing is that the HUGE array is about 200 records and really violates the readability of the method, so I tend to remove it from this class, but I'm not sure where to put it. Should I create a separate class for it or put it in a constant class Constants::getValue()or any other sentences? It would be wrong to remove it from this class, since it should be contained inside the object that it needs?
public function getValue($input) {
switch ($input) {
case 'in1' : { $value = array('wsj', 'kwo'); break; }
case 'in2' : { $value = array('wpo', 'ki2'); break; }
.....
default: { $value = array('wap', 'k90'); break; }
}
return $value;
}
source
share