ActionCard   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 3 1
A addButtons() 0 6 1
A single() 0 5 1
A setMessage() 0 8 1
1
<?php
2
3
namespace DingNotice\Messages;
4
5
use DingNotice\DingTalkService;
6
7
class ActionCard extends Message
8
{
9
10
    protected $service;
11
12
    public function __construct(DingTalkService $service,$title, $markdown, $hideAvatar = 0, $btnOrientation = 0)
13
    {
14
        $this->service = $service;
15
        $this->setMessage($title,$markdown,$hideAvatar,$btnOrientation);
16
    }
17
18
    public function setMessage($title, $markdown, $hideAvatar = 0, $btnOrientation = 0){
19
        $this->message = [
20
            'msgtype' => 'actionCard',
21
            'actionCard' => [
22
                'title' => $title,
23
                'text' => $markdown,
24
                'hideAvatar' => $hideAvatar,
25
                'btnOrientation' => $btnOrientation
26
            ]
27
        ];
28
    }
29
30
    public function single($title,$url){
31
        $this->message['actionCard']['singleTitle'] = $title;
32
        $this->message['actionCard']['singleURL'] = $url;
33
        $this->service->setMessage($this);
34
        return $this;
35
    }
36
37
    public function addButtons($title,$url){
38
        $this->message['actionCard']['btns'][] = [
39
            'title' => $title,
40
            'actionURL' => $url
41
        ];
42
        return $this;
43
    }
44
45
    public function send(){
46
        $this->service->setMessage($this);
47
        return $this->service->send();
48
    }
49
50
}