*/ namespace oat\taoItems\model\pack\encoders; use oat\tao\helpers\Base64; use oat\tao\model\media\MediaAsset; use tao_models_classes_FileNotFoundException; use oat\tao\model\media\sourceStrategy\HttpSource; /** * Class NoneEncoder * * @package oat\taoItems\model\pack\encoders */ class NoneEncoder implements Encoding { /** * NoneEncoder constructor. */ public function __construct() { } /** * @param mixed $data * * @throws tao_models_classes_FileNotFoundException * * @return mixed|string */ public function encode($data) { if ($data instanceof MediaAsset) { $mediaSource = $data->getMediaSource(); $mediaIdentifier = $data->getMediaIdentifier(); if ($mediaSource instanceof HttpSource || Base64::isEncodedImage($mediaIdentifier)) { return $mediaIdentifier; } return $mediaSource->getBaseName($mediaIdentifier); } return $data; } }