StaticSchema::getTable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Simply\Database;
4
5
/**
6
 * Schema implementation that provides the schema definition via static class properties.
7
 * @author Riikka Kalliomäki <[email protected]>
8
 * @copyright Copyright (c) 2018 Riikka Kalliomäki
9
 * @license http://opensource.org/licenses/mit-license.php MIT License
10
 */
11
abstract class StaticSchema extends Schema
12
{
13
    /** @var string The model class for models associated to the records */
14
    protected static $model = '';
15
16
    /** @var string The name of the table for the schema */
17
    protected static $table = '';
18
19
    /** @var string[]|string The primary key field or list of fields the make up the composite primary key */
20
    protected static $primaryKey = [];
21
22
    /** @var string[] List of all the fields in the table */
23
    protected static $fields = [];
24
25
    /** @var array[] The relationship definitions for the schema */
26
    protected static $relationships = [];
27
28 20
    public function getModel(): string
29
    {
30 20
        return static::$model;
31
    }
32
33 30
    public function getTable(): string
34
    {
35 30
        return static::$table;
36
    }
37
38 51
    public function getPrimaryKey(): array
39
    {
40 51
        return \is_array(static::$primaryKey) ? static::$primaryKey : [static::$primaryKey];
41
    }
42
43 59
    public function getFields(): array
44
    {
45 59
        return static::$fields;
46
    }
47
48 35
    public function getRelationshipDefinitions(): array
49
    {
50 35
        return static::$relationships;
51
    }
52
}
53