Completed
Push — master ( 26008b...b0b032 )
by Olivier
03:58
created

Table::getFixtures()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shapin\Datagen\DBAL;
6
7
use Doctrine\DBAL\Schema\Schema;
8
use Shapin\Datagen\DBAL\Exception\NoTableNameDefinedException;
9
10
abstract class Table extends FixtureCollection
11
{
12
    protected static $tableName;
13
14
    abstract public function addTableToSchema(Schema $schema);
15
16 10
    public static function getTableName(): string
17
    {
18 10
        if (null === static::$tableName) {
19
            throw new NoTableNameDefinedException(static::class);
20
        }
21
22 10
        return static::$tableName;
23
    }
24
25 4
    public function getFixtures(): iterable
26
    {
27 4
        foreach ($this->getRows() as $key => $fields) {
28 4
            yield $key => new Fixture(self::getTableName(), $fields, $this->getTypes());
29
        }
30 4
    }
31
32 2
    public function getRows(): iterable
33
    {
34 2
        return [];
35
    }
36
37 2
    public function getTypes(): array
38
    {
39 2
        return [];
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 7
    public function getProcessor(): string
46
    {
47 7
        return 'dbal';
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 7
    public function getName(): string
54
    {
55 7
        return self::getTableName();
56
    }
57
}
58