*
* @param $fieldName Name of the field we shall fetch
* @return $fieldValue Value from field
+ * @throws NullPointerException Thrown if $valueInstance is null
*/
public function getValueField ($fieldName) {
- // Construct the eval() command
- $eval = sprintf("\$fieldValue = \$this->getValueInstance()->getField('%s');",
- $fieldName
- );
+ // The $valueInstance attribute should not be null!
+ if (is_null($this->getValueInstance())) {
+ // Throws an exception here
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
// Get the field value
- eval($eval);
+ $fieldValue = $this->getValueInstance()->getField($fieldName);
// Return it
return $fieldValue;