protected function cleanSerial($serial)
    {
        if ($serial instanceof \core_kernel_classes_Resource) {
            $serial = $serial->getUri();
        } elseif ($serial instanceof \core_kernel_classes_Literal) {
            $serial = $serial->__toString();
        } elseif (!is_string($serial)) {
            throw new FileSerializerException('Unsupported serial "'.gettype($serial).'" in '.__CLASS__);
        }

        return $serial;
    }