<?php

namespace App\Importer;

class ImportDataFactory
{
    /**
     * Instanciate an import data class depending on given file.
     *
     * @param  string  $filepath
     * @return \Gallib\Macope\Importer\ImportDataInterface
     */
    public static function create($filepath)
    {
        $factory = new PostFinanceImport($filepath);

        if ($factory->isValid()) {
            return $factory;
        }

        $factory = new MigrosBankImport($filepath);

        if ($factory->isValid()) {
            return $factory;
        }

        throw new \InvalidArgumentException("{$filepath->getClientOriginalName()} is not a valid file");
    }
}

<?php

namespace App\Importer;

class ImportDataFactory
{
    /**
     * Instanciate an import data class depending on given file.
     *
     * @param  string  $filepath
     * @return \Gallib\Macope\Importer\ImportDataInterface
     */
    public static function create($filepath)
    {
        $factory = new PostFinanceImport($filepath);

        if ($factory->isValid()) {
            return $factory;
        }

        $factory = new MigrosBankImport($filepath);

        if ($factory->isValid()) {
            return $factory;
        }

        throw new \InvalidArgumentException("File is not valid");
    }
}

Fix bug where filepath is a string
Fix bug where filepath is a string
