Passed
Push — master ( a325c0...46b506 )
by 世昌
02:20
created

MiddlewareAwareTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMiddleware() 0 6 2
1
<?php
2
namespace suda\orm\middleware;
3
4
use suda\orm\TableStruct;
5
use suda\orm\middleware\Middleware;
6
use suda\orm\struct\TableStructMiddleware;
7
8
/**
9
 * 感知表结构
10
 */
11
trait MiddlewareAwareTrait
12
{
13
    /**
14
     * 表结构
15
     *
16
     * @var Middleware
17
     */
18
    protected static $middleware;
19
20
    public static function getMiddleware(TableStruct $struct):Middleware
21
    {
22
        if (static::$middleware === null) {
23
            static::$middleware = static::createMiddleware($struct);
24
        }
25
        return static::$middleware;
26
    }
27
28
    abstract public static function createMiddleware(TableStruct $struct):Middleware;
29
}
30