Schema::__construct()   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
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace mindplay\sql\model\schema;
4
5
use mindplay\sql\model\TableFactory;
6
7
/**
8
 * This is an abstract base-class for user-defined Schema-types.
9
 */
10
abstract class Schema
11
{
12
    private TableFactory $factory;
13
14 1
    public function __construct(TableFactory $factory)
15
    {
16 1
        $this->factory = $factory;
17
    }
18
19
    /**
20
     * This name is used to qualify table-references, e.g. using schema-names in Postgres, or
21
     * table-name prefixes in MySQL.
22
     *
23
     * The default implementation returns NULL - override this in your Schema implementation, if needed.
24
     *
25
     * @return string|null optional Schema-name, or NULL
26
     */
27
    public function getName(): string|null
28
    {
29
        return null;
30
    }
31
32
    /**
33
     * @param $class_name Table class-name
34
     * @param $table_name relational table-name
0 ignored issues
show
Bug introduced by
The type mindplay\sql\model\schema\relational was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
     * @param $alias      optional Table alias
0 ignored issues
show
Bug introduced by
The type mindplay\sql\model\schema\optional was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
36
     */
37 1
    protected function createTable(string $class_name, string $table_name, string|null $alias = null): Table
38
    {
39 1
        return $this->factory->createTable($this, $class_name, $table_name, $alias);
40
    }
41
42
    /**
43
     * @ignore
44
     *
45
     * @param string $name
46
     *
47
     * @return Table
48
     */
49 1
    public function __get($name)
50
    {
51
        // TODO caching
52
53 1
        return $this->$name(null);
54
    }
55
}
56