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

DataObject::jsonSerialize()   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\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