Passed
Push — sudav3 ( d2f44f...2e4700 )
by 世昌
02:35
created

MagicArrayAccessTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetGet() 0 3 1
A offsetExists() 0 3 1
A offsetSet() 0 3 1
A offsetUnset() 0 3 1
1
<?php
2
namespace suda\orm\struct;
3
4
trait MagicArrayAccessTrait
5
{
6
    public function offsetSet($offset, $value)
7
    {
8
        $this->__set($offset, $value);
9
    }
10
11
    public function offsetExists($offset)
12
    {
13
        return $this->__isset($offset);
14
    }
15
16
    public function offsetUnset($offset)
17
    {
18
        $this->__unset($offset);
19
    }
20
21
    public function offsetGet($offset)
22
    {
23
        return $this->__get($offset);
24
    }
25
26
    /**
27
     * 设置值
28
     *
29
     * @param string $name
30
     * @param mixed $value
31
     */
32
    abstract public function __set(string $name, $value);
33
    
34
    /**
35
     * 获取参数值
36
     *
37
     * @param string $name
38
     * @return mixed
39
     */
40
    abstract public function __get(string $name);
41
42
    /**
43
     * 判断是否设置
44
     *
45
     * @param string $name
46
     * @return boolean
47
     */
48
    abstract public function __isset(string $name);
49
50
    /**
51
     * 取消设置值
52
     *
53
     * @param string $name
54
     */
55
    abstract public function __unset(string $name);
56
}
57