MySQLDataFactory::createData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * This file is part of the CRUDlex package.
5
 *
6
 * (c) Philip Lehmann-Böhm <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CRUDlex;
13
14
use Doctrine\DBAL\Connection;
15
use League\Flysystem\FilesystemInterface;
16
17
/**
18
 * A factory implementation for MySQLData instances.
19
 */
20
class MySQLDataFactory implements DataFactoryInterface
21
{
22
23
    /**
24
     * Holds the Doctrine DBAL instance.
25
     * @var Connection
26
     */
27
    protected $database;
28
29
    /**
30
     * Flag whether to use UUIDs as primary key.
31
     * @var bool
32
     */
33
    protected $useUUIDs;
34
35
    /**
36
     * Constructor.
37
     *
38
     * @param $database
39
     * the Doctrine DBAL instance
40
     * @param $useUUIDs
41
     * flag whether to use UUIDs as primary key
42
     */
43 81
    public function __construct(Connection $database, $useUUIDs = false)
44
    {
45 81
        $this->database = $database;
46 81
        $this->useUUIDs = $useUUIDs;
47 81
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 79
    public function createData(EntityDefinition $definition, FilesystemInterface $filesystem)
53
    {
54 79
        return new MySQLData($definition, $filesystem, $this->database, $this->useUUIDs);
55
    }
56
57
}
58