AbstractMessage   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 82
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 4 1
A __get() 0 8 2
A __set() 0 10 2
1
<?php
2
3
namespace EntWeChat\Message;
4
5
use EntWeChat\Support\Attribute;
6
7
/**
8
 * Class AbstractMessage.
9
 */
10
abstract class AbstractMessage extends Attribute
11
{
12
    /**
13
     * Message type.
14
     *
15
     * @var string
16
     */
17
    protected $type;
18
19
    /**
20
     * Message id.
21
     *
22
     * @var int
23
     */
24
    protected $id;
25
26
    /**
27
     * Message target user open id.
28
     *
29
     * @var string
30
     */
31
    protected $to;
32
33
    /**
34
     * Message sender open id.
35
     *
36
     * @var string
37
     */
38
    protected $from;
39
40
    /**
41
     * Message attributes.
42
     *
43
     * @var array
44
     */
45
    protected $properties = [];
46
47
    /**
48
     * Return type name message.
49
     *
50
     * @return string
51
     */
52
    public function getType()
53
    {
54
        return $this->type;
55
    }
56
57
    /**
58
     * Magic getter.
59
     *
60
     * @param string $property
61
     *
62
     * @return mixed
63
     */
64
    public function __get($property)
65
    {
66
        if (property_exists($this, $property)) {
67
            return $this->$property;
68
        }
69
70
        return parent::__get($property);
71
    }
72
73
    /**
74
     * Magic setter.
75
     *
76
     * @param string $property
77
     * @param mixed  $value
78
     *
79
     * @return AbstractMessage
80
     */
81
    public function __set($property, $value)
82
    {
83
        if (property_exists($this, $property)) {
84
            $this->$property = $value;
85
        } else {
86
            parent::__set($property, $value);
87
        }
88
89
        return $this;
90
    }
91
}
92