public function transform($value = null) { if ($value === null) { return null; } if (!$value instanceof Identifiable) { throw new TransformationFailedException('Value was not instance of Identifiable, type was: "' . \NGS\Utils::getType($value) . '"'); } return $value->URI; }
public function transform($value) { if ($value instanceof Timestamp) { return $value->format($this->format); } if (is_string($value)) { return $value; } // By convention, transform() should return an empty string if NULL is passed. if ($value === null) { return ''; } throw new TransformationFailedException('Could not transform value to string, was expecting NGS\\Timestamp, but given value was type :"' . \NGS\Utils::getType($value) . '"'); }
public function transform($value) { if ($value instanceof LocalDate) { $date = $value->toDateTime(); return $date->format($this->format); } else { if (is_string($value)) { return $value; } else { if ($value === null) { return ""; } else { throw new TransformationFailedException('Could not convert LocalDate value to string from type:"' . \NGS\Utils::getType($value) . '"'); } } } }
public function reverseTransform($value) { if ($value === null) { return null; } try { if ($value instanceof UploadedFile) { $contents = ''; $file = $value->openFile(); while (!$file->eof()) { $contents .= $file->fgets(); } return new ByteStream($contents, false); } else { if (is_string($value)) { return new ByteStream($value); } else { throw new TransformationFailedException('Could not transform value from "' . \NGS\Utils::gettype($value) . '" to NGS\\Bytestream'); } } } catch (InvalidArgumentException $ex) { throw new TransformationFailedException($ex->getMessage()); } }