FluentPdoFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 2
1
<?php
2
/**
3
 * Copyright (c) 2017
4
 *
5
 * @package   Majima
6
 * @author    David Neustadt <[email protected]>
7
 * @copyright 2017 David Neustadt
8
 * @license   MIT
9
 */
10
11
namespace Majima\Services;
12
use Symfony\Component\DependencyInjection\Container;
13
14
/**
15
 * Class FluentPdoFactory
16
 * @package Majima\Services
17
 */
18
class FluentPdoFactory extends \FluentPDO
19
{
20
    /**
21
     * @var Container
22
     */
23
    private $container;
24
25
    /**
26
     * @var \PDO
27
     */
28
    private $PDO;
29
30
    /**
31
     * FluentPdoFactory constructor.
32
     * @param Container $container
33
     */
34
    public function __construct(Container $container)
35
    {
36
        $this->container = $container;
37
        if ($container->hasParameter('db_config_loaded')) {
38
            $this->PDO = new \PDO(
39
                sprintf(
40
                    "mysql:host=%s;port=%s;dbname=%s",
41
                    $container->getParameter('db_host'),
42
                    $container->getParameter('db_port'),
43
                    $container->getParameter('db_name')
44
                ),
45
                $container->getParameter('db_user'),
46
                $container->getParameter('db_passw')
47
            );
48
49
            parent::__construct($this->PDO);
50
        }
51
    }
52
}