<commit_before><?php

namespace Backend\Doctrine\Entity;

use Doctrine\DBAL\Exception\TableExistsException;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\SchemaTool;

class CreateSchema
{
    /** @var EntityManager */
    private $entityManager;

    /**
     * @param EntityManager $entityManager
     */
    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    /**
     * Adds a new doctrine entity in the database
     *
     * @param string $entityClass
     */
    public function forEntityClass($entityClass)
    {
        $this->forEntityClasses([$entityClass]);
    }

    /**
     * Adds new doctrine entities in the database
     *
     * @param array $entityClasses
     */
    public function forEntityClasses(array $entityClasses)
    {
        // create the database table for the given class using the doctrine SchemaTool
        $schemaTool = new SchemaTool($this->entityManager);

        try {
            $schemaTool->createSchema(
                array_map(
                    function ($entityClass) {
                        return $this->entityManager->getClassMetadata($entityClass);
                    },
                    $entityClasses
                )
            );
        } catch (TableExistsException $tableExists) {
            // do nothing because it already exists in the database
        }
    }
}<commit_msg>Use a callable instead of an annonymous function<commit_after><?php

namespace Backend\Doctrine\Entity;

use Doctrine\DBAL\Exception\TableExistsException;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\SchemaTool;

class CreateSchema
{
    /** @var EntityManager */
    private $entityManager;

    /**
     * @param EntityManager $entityManager
     */
    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    /**
     * Adds a new doctrine entity in the database
     *
     * @param string $entityClass
     */
    public function forEntityClass($entityClass)
    {
        $this->forEntityClasses([$entityClass]);
    }

    /**
     * Adds new doctrine entities in the database
     *
     * @param array $entityClasses
     */
    public function forEntityClasses(array $entityClasses)
    {
        // create the database table for the given class using the doctrine SchemaTool
        $schemaTool = new SchemaTool($this->entityManager);

        try {
            $schemaTool->createSchema(
                array_map(
                    array($this->entityManager, 'getClassMetadata'),
                    $entityClasses
                )
            );
        } catch (TableExistsException $tableExists) {
            // do nothing because it already exists in the database
        }
    }
}
{'fraction_non_alphanumeric': 0.09045584045584046, 'fraction_numerical': 0.0, 'mean_word_length': 2.1176470588235294, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, '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': '5704443', 'n_tokens_mistral': 717, 'n_tokens_neox': 701, 'n_words': 181}