<?php

namespace idoit\Module\QCW;

use idoit\Component\Download\DownloadType;
use isys_module_quick_configuration_wizard;

/**
 * i-doit QCW profile download type.
 *
 * @package     Modules
 * @subpackage  QCW
 * @copyright   synetics GmbH
 * @license     http://www.i-doit.com/license
 */
class ProfileDownloadType extends DownloadType
{
    /**
     *
     */
    public function __construct()
    {
        parent::__construct([self::class, 'downloadXml']);
    }

    /**
     * @param string $fileName
     * @return string|null
     */
    public static function downloadXml(string $fileName): ?string
    {
        $uploadDir = isys_module_quick_configuration_wizard::getProfilePath();
        $fileName = trim(basename($fileName));

        if (!file_exists($uploadDir . $fileName)) {
            return null;
        }

        return $uploadDir . $fileName;
    }
}
