<commit_before><?php

namespace Gitonomy\Bundle\CoreBundle\Git;

use Gitonomy\Bundle\CoreBundle\Entity\Project;
use Gitonomy\Bundle\CoreBundle\EventListener\Event\ProjectCreateEvent;
use Gitonomy\Git;

/**
 * Repository pool, containing all Git repositories.
 *
 * @author <NAME> <<EMAIL>>
 */
class RepositoryPool
{
    /**
     * Root directory of every repositories.
     *
     * @var string
     */
    protected $repositoryPath;

    /**
     * Constructor.
     *
     * @param string $repositoryPath Path to the repository root folder
     */
    public function __construct($repositoryPath)
    {
        $this->repositoryPath = $repositoryPath;
    }

    public function onProjectCreate(ProjectCreateEvent $event)
    {
        $this->create($event->getProject());
    }

    /**
     * Returns the Git repository associated the a model project.
     *
     * @param Gitonomy\Bundle\CoreBundle\Entity\Project $project A
     * project model instance
     *
     * @return Gitonomy\Git\Repository A Git repository
     */
    public function getGitRepository(Project $project)
    {
        return new Git\Repository($this->getPath($project));
    }

    /**
     * Creates a new Git repository.
     *
     * @param Gitonomy\Bundle\CoreBundle\Entity\Project $project A
     * project model instance
     */
    protected function create(Project $project)
    {
        $path = $this->getPath($project);

        if (is_dir($path)) {
            throw new \RuntimeException(sprintf('The folder "%s" already exists', $path));
        }

        Git\Admin::init($path);
    }

    /**
     * Computes the repository path for a given project.
     */
    protected function getPath(Project $project)
    {
        return $this->repositoryPath.'/'.$project->getSlug().'.git';
    }
}<commit_msg>Simplify some code<commit_after><?php

namespace Gitonomy\Bundle\CoreBundle\Git;

use Gitonomy\Bundle\CoreBundle\Entity\Project;
use Gitonomy\Bundle\CoreBundle\EventListener\Event\ProjectCreateEvent;
use Gitonomy\Git;

/**
 * Repository pool, containing all Git repositories.
 *
 * @author <NAME> <<EMAIL>>
 */
class RepositoryPool
{
    /**
     * Root directory of every repositories.
     *
     * @var string
     */
    protected $repositoryPath;

    /**
     * Constructor.
     *
     * @param string $repositoryPath Path to the repository root folder
     */
    public function __construct($repositoryPath)
    {
        $this->repositoryPath = $repositoryPath;
    }

    /**
     * Method called when a project is created
     */
    public function onProjectCreate(ProjectCreateEvent $event)
    {
        $path = $this->getPath($event->getProject());

        if (is_dir($path)) {
            throw new \RuntimeException(sprintf('The folder "%s" already exists', $path));
        }

        Git\Admin::init($path);
    }

    /**
     * Returns the Git repository associated the a model project.
     *
     * @param Gitonomy\Bundle\CoreBundle\Entity\Project $project A
     * project model instance
     *
     * @return Gitonomy\Git\Repository A Git repository
     */
    public function getGitRepository(Project $project)
    {
        return new Git\Repository($this->getPath($project));
    }

    /**
     * Computes the repository path for a given project.
     */
    protected function getPath(Project $project)
    {
        return $this->repositoryPath.'/'.$project->getSlug().'.git';
    }
}
{'fraction_non_alphanumeric': 0.11874817198011114, 'fraction_numerical': 0.0, 'mean_word_length': 2.5625, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 22, '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': '6267227', 'n_tokens_mistral': 964, 'n_tokens_neox': 937, 'n_words': 232}