Completed
Push — master ( 38310f...b83e6e )
by Matthew
08:14
created

getDoctrine_Orm_DefaultEntityManagerService()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
cc 2
eloc 21
nc 2
nop 1
1
<?php
2
3
namespace Dtc\QueueBundle\Tests\ORM;
4
5
use Doctrine\ORM\EntityManager;
6
use Symfony\Component\DependencyInjection\Container;
7
use Doctrine\ORM\Tools\Setup;
8
9
class ContainerExtended extends Container
10
{
11
    protected $methodMap = ['doctrine.orm.default_entity_manager' => 'getDoctrine_Orm_DefaultEntityManagerService'];
12
13
    public function getDoctrine_Orm_DefaultEntityManagerService($something = false)
0 ignored issues
show
Unused Code introduced by
The parameter $something is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
14
    {
15
        $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__.'/../..'), true, null, null, false);
16
        $namingStrategy = new \Doctrine\ORM\Mapping\UnderscoreNamingStrategy();
17
        $config->setNamingStrategy($namingStrategy);
18
        $config->addCustomNumericFunction('year', Year::class);
19
        $config->addCustomNumericFunction('month', Month::class);
20
        $config->addCustomNumericFunction('day', Day::class);
21
        $config->addCustomNumericFunction('hour', Hour::class);
22
        $config->addCustomNumericFunction('minute', Minute::class);
23
        $host = getenv('MYSQL_HOST');
24
        $user = getenv('MYSQL_USER');
25
        $port = getenv('MYSQL_PORT') ?: 3306;
26
        $password = getenv('MYSQL_PASSWORD');
27
        $db = getenv('MYSQL_DATABASE');
28
        $params = ['host' => $host,
29
            'port' => $port,
30
            'user' => $user,
31
            'driver' => 'mysqli',
32
            'password' => $password,
33
            'dbname' => $db, ];
34
35
        return EntityManager::create($params, $config);
36
    }
37
}
38