Passed
Push — sudav3 ( b29c56...468d62 )
by 世昌
02:20
created

TableStructAwareTrait::createStruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace suda\orm\struct;
3
4
/**
5
 * 感知表结构
6
 */
7
trait TableStructAwareTrait
8
{
9
    /**
10
     * 表结构
11
     *
12
     * @var TableStruct
13
     */
14
    private static $struct;
15
16
    public static function getTableStruct():TableStruct
17
    {
18
        if (static::$struct === null) {
0 ignored issues
show
Bug introduced by
Since $struct is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $struct to at least protected.
Loading history...
19
            static::$struct = static::createStruct();
20
        }
21
        return static::$struct;
22
    }
23
24
    public static function createStruct():TableStruct
25
    {
26
        return (new TableStructBuilder(static::class))->createStruct();
0 ignored issues
show
Bug Best Practice introduced by
The expression return new suda\orm\stru...:class)->createStruct() returns the type suda\orm\TableStruct which is incompatible with the type-hinted return suda\orm\struct\TableStruct.
Loading history...
27
    }
28
}
29