At   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 59
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0
wmc 9

4 Methods

Rating   Name   Duplication   Size   Complexity  
A atAll() 0 4 1
A at() 0 8 4
A notAtAll() 0 4 1
A getAt() 0 11 3
1
<?php
2
3
namespace DingRobot\Message\Traits;
4
5
trait At
6
{
7
    protected $mobiles = [];
8
    protected $all = false;
9
10
    /**
11
     * at 某人
12
     * at someone
13
     *
14
     * @param string|array $someone
15
     *
16
     * @return $this
17
     */
18 6
    public function at($someone = null)
19
    {
20 6
        if (is_string($someone) || is_numeric($someone)) {
21 6
            $this->mobiles[] = (string)$someone;
22 6
        } elseif (is_array($someone)) {
23 6
            $this->mobiles = array_merge($this->mobiles, $someone);
24
        }
25 6
        return $this;
26
    }
27
28
    /**
29
     * set at all active
30
     * at 全部人
31
     *
32
     * @return $this
33
     */
34 6
    public function atAll()
35
    {
36 6
        $this->all = true;
37 6
        return $this;
38
    }
39
40
    /**
41
     * cancel at all
42
     * 取消 at 全部人
43
     *
44
     * @return $this
45
     */
46 6
    public function notAtAll()
47
    {
48 6
        $this->all = false;
49 6
        return $this;
50
    }
51
52
53 8
    protected function getAt()
54
    {
55 8
        if (count($this->mobiles) || $this->all) {
56
            return [
57
                'at' => [
58 6
                    'atMobiles' => $this->mobiles,
59 6
                    'isAtAll'   => $this->all,
60
                ]
61
            ];
62
        } else {
63 2
            return [];
64
        }
65
    }
66
}