Passed
Push — master ( 3570a0...a325c0 )
by 世昌
02:04
created

DataObject   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkFieldExist() 0 3 1
A jsonSerialize() 0 3 1
1
<?php
2
namespace suda\application\database;
3
4
use suda\orm\middleware\Middleware;
5
use suda\orm\struct\ArrayDataTrait;
6
use suda\orm\struct\WriteStatement;
7
use suda\orm\struct\ArrayDataInterface;
8
use suda\application\database\DataAccess;
9
use suda\orm\struct\TableStructAwareTrait;
10
use suda\orm\struct\TableStructAwareInterface;
11
use suda\application\database\TableMiddlewareTrait;
12
13
/**
14
 * 数据表抽象对象
15
 *
16
 * 用于提供对数据表的操作
17
 *
18
 */
19
abstract class DataObject implements TableStructAwareInterface, ArrayDataInterface, Middleware
20
{
21
    use ArrayDataTrait;
22
    use TableStructAwareTrait;
23
    use TableMiddlewareTrait;
24
    
25
    /**
26
     * 检查字段是否存在
27
     *
28
     * @param string $name
29
     * @return boolean
30
     */
31
    public function checkFieldExist(string $name)
32
    {
33
        return static::getTableStruct()->getFields()->hasField($name);
34
    }
35
36
    /**
37
     * 获取序列化对象
38
     *
39
     * @return array
40
     */
41
    public function jsonSerialize()
42
    {
43
        return $this->data;
44
    }
45
}
46