protected function resolveTargetFilePath($target, $basePath)
    {
        switch (true) {

            // resource
            case strpos($target, '@') === 0:
                $targetPath = $this->fileLocator->locate($target);
                break;

            // kernel related
            case strpos($target, '/') === 0:
                $targetPath = sprintf('%s%s',
                    $this->kernelDir,
                    $target
                );
                break;

            // related file
            default:
                $targetPath = sprintf('%s/%s', $basePath, $target);
                break;
        }

        if (!is_writable($targetPath)) {
            throw new \InvalidArgumentException(sprintf(
                'Unable to resolve "%s" target, resolved into "%s" file path which is not writable.',
                $target,
                $targetPath
            ));
        }

        return $targetPath;
    }