TIMCombinationElem   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 30
ccs 8
cts 12
cp 0.6667
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A transformToJson() 0 3 1
A transformToArray() 0 9 2
A getType() 0 3 1
1
<?php
2
3
namespace EasyIM\TencentIM\Kernel\Messages;
4
5
use EasyIM\Kernel\Contracts\MessageInterface;
6
7
/**
8
 * Class TIMCombinationElem
9
 *
10
 * @package EasyIM\TencentIM\Kernel\Messages
11
 * @author  longing <[email protected]>
12
 */
13
class TIMCombinationElem implements MessageInterface
14
{
15
    public $type = 'TIMCombinationElem';
16
17
    protected $messages = [];
18
19 2
    public function __construct(Message ...$messages)
20
    {
21 2
        $this->messages = $messages;
22 2
    }
23
24 2
    public function transformToArray(array $appends = [], bool $isFlat = true): array
25
    {
26 2
        $msgBody = [];
27
28 2
        foreach ($this->messages as $message) {
29 2
            $msgBody[] = $message->transformToArray($appends, $isFlat);
30
        }
31
32 2
        return $msgBody;
33
    }
34
35
    public function getType(): string
36
    {
37
        return $this->type;
38
    }
39
40
    public function transformToJson(): string
41
    {
42
        return json_encode($this->transformToArray());
43
    }
44
}
45