Passed
Push — master ( 566a3a...fbef46 )
by 世昌
02:19
created

MagicArrayAccessTrait::offsetExists()   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 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace suda\database\struct;
3
4
/**
5
 * Trait MagicArrayAccessTrait
6
 * @package suda\orm\struct
7
 */
8
trait MagicArrayAccessTrait
9
{
10
    /**
11
     * @param $offset
12
     * @param $value
13
     */
14
    public function offsetSet($offset, $value)
15
    {
16
        $this->__set($offset, $value);
17
    }
18
19
    /**
20
     * @param $offset
21
     * @return bool
22
     */
23
    public function offsetExists($offset)
24
    {
25
        return $this->__isset($offset);
26
    }
27
28
    /**
29
     * @param $offset
30
     */
31
    public function offsetUnset($offset)
32
    {
33
        $this->__unset($offset);
34
    }
35
36
    /**
37
     * @param $offset
38
     * @return mixed
39
     */
40
    public function offsetGet($offset)
41
    {
42
        return $this->__get($offset);
43
    }
44
45
    /**
46
     * 设置值
47
     *
48
     * @param string $name
49
     * @param mixed $value
50
     */
51
    abstract public function __set(string $name, $value);
52
    
53
    /**
54
     * 获取参数值
55
     *
56
     * @param string $name
57
     * @return mixed
58
     */
59
    abstract public function __get(string $name);
60
61
    /**
62
     * 判断是否设置
63
     *
64
     * @param string $name
65
     * @return boolean
66
     */
67
    abstract public function __isset(string $name);
68
69
    /**
70
     * 取消设置值
71
     *
72
     * @param string $name
73
     */
74
    abstract public function __unset(string $name);
75
}
76