SmartApiCommands::errorResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: 5729906803
5
 * Date: 9/13/2020
6
 * Time: 1:04 PM
7
 */
8
9
namespace Hsy\SimotelConnect;
10
11
12
trait SmartApiCommands
13
{
14
    private $apiCommands;
15
16
    private function addCommand($command)
17
    {
18
        $this->apiCommands[] = $command;
19
    }
20
21
    private function render()
22
    {
23
        $commands = implode(";", $this->apiCommands);
24
        $this->apiCommands = [];
25
        return $commands;
26
    }
27
28
    private function okResponse()
29
    {
30
        return ["ok" => 1,
31
            "commands" => $this->render()];
32
    }
33
34
    private function errorResponse()
35
    {
36
        return ["ok" => 0];
37
    }
38
39
    /*
40
     *
41
     */
42
    private function cmdPlayAnnouncement($file)
43
    {
44
        $this->addCommand("PlayAnnouncement('$file')");
45
    }
46
47
    /*
48
     *
49
     */
50
    private function cmdPlayback($file)
51
    {
52
        $this->addCommand("Playback('$file')");
53
    }
54
55
    /*
56
     *
57
     */
58
    private function cmdExit($exit)
59
    {
60
        $this->addCommand("Exit('$exit')");
61
    }
62
63
    /*
64
     *
65
     */
66
    private function cmdGetData($file,$timeout,$digitsCount)
67
    {
68
        $this->addCommand("GetData('$file',$timeout,$digitsCount)");
69
    }
70
71
    /*
72
     *
73
     */
74
    private function cmdSayDigit($number)
75
    {
76
        $this->addCommand("SayDigit($number)");
77
    }
78
79
    /*
80
     *
81
     */
82
    private function cmdSayNumber($number)
83
    {
84
        $this->addCommand("SayNumber($number)");
85
    }
86
87
    /*
88
     *
89
     */
90
    private function cmdSayClock($clock)
91
    {
92
        $this->addCommand("SayClock($clock)");
93
    }
94
95
    /*
96
     *
97
     */
98
    private function cmdSayDate($date,$calender)
99
    {
100
        $this->addCommand("SayDate('$date','$calender')");
101
    }
102
103
    /*
104
     *
105
     */
106
    private function cmdSayDuration($duration)
107
    {
108
        $this->addCommand("SayDuration('$duration')");
109
    }
110
111
    /*
112
    *
113
    */
114
    private function cmdSetExten($exten)
115
    {
116
        $this->addCommand("SetExten('$exten')");
117
    }
118
    /*
119
     * Set limit on call
120
     */
121
    private function cmdSetLimitOnCall($seconds)
122
    {
123
        $this->addCommand("SetLimitOnCall($seconds)");
124
    }
125
}
126