<commit_before><?php
/*
 * This file is part of the CampaignChain package.
 *
 * (c) CampaignChain, Inc. <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CampaignChain\CoreBundle\Fixture;

use CampaignChain\CoreBundle\EntityService\UserService;
use CampaignChain\CoreBundle\Util\SystemUtil;
use Doctrine\ORM\EntityManager;
use h4cc\AliceFixturesBundle\Fixtures\FixtureManager;
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesserInterface;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;

class FileLoader
{
    /**
     * @var UserService
     */
    private $userService;

    /**
     * @var FixtureManager
     */
    private $fixtureManager;

    /**
     * @var EntityManager
     */
    private $em;

    /**
     * @var MimeTypeGuesserInterface
     */
    private $mimeTypeGuesser;

    /**
     * @var ExtensionGuesserInterface
     */
    private $extensionGuesser;

    /**
     * @var \Exception
     */
    private $exception;

    /**
     * SampleDataUtil constructor.
     * @param UserService $userService
     * @param FixtureManager $fixtureManager
     * @param EntityManager $em
     * @param MimeTypeGuesserInterface $mimeTypeGuesser
     * @param ExtensionGuesserInterface $extensionGuesser
     */
    public function __construct(
        UserService $userService, FixtureManager $fixtureManager,
        EntityManager $em, MimeTypeGuesserInterface $mimeTypeGuesser,
        ExtensionGuesserInterface $extensionGuesser
    )
    {
        $this->userService = $userService;
        $this->fixtureManager = $fixtureManager;
        $this->em = $em;
        $this->mimeTypeGuesser = $mimeTypeGuesser;
        $this->extensionGuesser = $extensionGuesser;
    }

    /**
     * @param array $files
     * @param bool $doDrop
     */
    public function load(array $files, $doDrop = true)
    {
        try {
            $this->em->getConnection()->beginTransaction();

            $userProcessor = new UserProcessor(
                realpath(SystemUtil::getRootDir()), $this->userService,
                $this->mimeTypeGuesser, $this->extensionGuesser
            );<commit_msg>CampaignChain/campaignchain#176 Command for loading sample data<commit_after><?php
/*
 * This file is part of the CampaignChain package.
 *
 * (c) CampaignChain, Inc. <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CampaignChain\CoreBundle\Fixture;

use CampaignChain\CoreBundle\EntityService\UserService;
use CampaignChain\CoreBundle\Util\SystemUtil;
use Doctrine\ORM\EntityManager;
use h4cc\AliceFixturesBundle\Fixtures\FixtureManager;
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesserInterface;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;

class FileLoader
{
    /**
     * @var UserService
     */
    private $userService;

    /**
     * @var FixtureManager
     */
    private $fixtureManager;

    /**
     * @var EntityManager
     */
    private $em;

    /**
     * @var MimeTypeGuesserInterface
     */
    private $mimeTypeGuesser;

    /**
     * @var ExtensionGuesserInterface
     */
    private $extensionGuesser;

    /**
     * @var \Exception
     */
    private $exception;

    /**
     * SampleDataUtil constructor.
     * @param UserService $userService
     * @param FixtureManager $fixtureManager
     * @param EntityManager $em
     * @param MimeTypeGuesserInterface $mimeTypeGuesser
     * @param ExtensionGuesserInterface $extensionGuesser
     */
    public function __construct(
        UserService $userService, FixtureManager $fixtureManager,
        EntityManager $em, MimeTypeGuesserInterface $mimeTypeGuesser,
        ExtensionGuesserInterface $extensionGuesser
    )
    {
        $this->userService = $userService;
        $this->fixtureManager = $fixtureManager;
        $this->em = $em;
        $this->mimeTypeGuesser = $mimeTypeGuesser;
        $this->extensionGuesser = $extensionGuesser;
    }

    /**
     * @param array $files
     * @param bool $doDrop
     */
    public function load(array $files, $doDrop = true)
    {
        try {
            $this->em->getConnection()->beginTransaction();

            $userProcessor = new UserProcessor(
                realpath(
                    SystemUtil::getRootDir().DIRECTORY_SEPARATOR.
                    'vendor'.DIRECTORY_SEPARATOR
                ),
                $this->userService, $this->mimeTypeGuesser, $this->extensionGuesser
            );
{'fraction_non_alphanumeric': 0.10068699012451696, 'fraction_numerical': 0.00107342206955775, 'mean_word_length': 2.73616680032077, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3704522', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1326, 'n_words': 273}