Playback::onPlaybackStarted()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/*
4
 * Copyright 2014 Brian Smith <[email protected]>.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *      http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace phparia\Resources;
20
21
use phparia\Client\AriClient;
22
use phparia\Events\Event;
23
24
/**
25
 * Description of Playback
26
 *
27
 * @author Brian Smith <[email protected]>
28
 */
29
class Playback extends Resource
30
{
31
    /**
32
     * @var string ID for this playback operation
33
     */
34
    private $id;
35
36
    /**
37
     * @var string (optional) - For media types that support multiple languages, the language requested for playback.
38
     */
39
    private $language;
40
41
    /**
42
     * @var string URI for the media to play back.
43
     */
44
    private $mediaUri;
45
46
    /**
47
     * @var string Current state of the playback operation.
48
     */
49
    private $state;
50
51
    /**
52
     * @var string URI for the channel or bridge to play the media on
53
     */
54
    private $targetUri;
55
56
    /**
57
     * @return string ID for this playback operation
58
     */
59
    public function getId()
60
    {
61
        return $this->id;
62
    }
63
64
    /**
65
     * @return string (optional) - For media types that support multiple languages, the language requested for playback.
66
     */
67
    public function getLanguage()
68
    {
69
        return $this->language;
70
    }
71
72
    /**
73
     * @return string URI for the media to play back.
74
     */
75
    public function getMediaUri()
76
    {
77
        return $this->mediaUri;
78
    }
79
80
    /**
81
     * @return string Current state of the playback operation.
82
     */
83
    public function getState()
84
    {
85
        return $this->state;
86
    }
87
88
    /**
89
     * @return string URI for the channel or bridge to play the media on
90
     */
91
    public function getTargetUri()
92
    {
93
        return $this->targetUri;
94
    }
95
96
    /**
97
     * @param callable $callback
98
     */
99
    public function onPlaybackStarted(callable $callback)
100
    {
101
        $this->on(Event::PLAYBACK_STARTED.'_'.$this->getId(), $callback);
102
    }
103
104
    /**
105
     * @param callable $callback
106
     */
107
    public function oncePlaybackStarted(callable $callback)
108
    {
109
        $this->once(Event::PLAYBACK_STARTED.'_'.$this->getId(), $callback);
110
    }
111
112
    /**
113
     * @param callable $callback
114
     */
115
    public function onPlaybackContinuing(callable $callback)
116
    {
117
        $this->on(Event::PLAYBACK_CONTINUING.'_'.$this->getId(), $callback);
118
    }
119
120
    /**
121
     * @param callable $callback
122
     */
123
    public function oncePlaybackContinuing(callable $callback)
124
    {
125
        $this->once(Event::PLAYBACK_CONTINUING.'_'.$this->getId(), $callback);
126
    }
127
128
    /**
129
     * @param callable $callback
130
     */
131
    public function onPlaybackFinished(callable $callback)
132
    {
133
        $this->on(Event::PLAYBACK_FINISHED.'_'.$this->getId(), $callback);
134
    }
135
136
    /**
137
     * @param callable $callback
138
     */
139
    public function oncePlaybackFinished(callable $callback)
140
    {
141
        $this->once(Event::PLAYBACK_FINISHED.'_'.$this->getId(), $callback);
142
    }
143
144
    /**
145
     * @param AriClient $client
146
     * @param string $response
147
     */
148 View Code Duplication
    public function __construct(AriClient $client, $response)
149
    {
150
        parent::__construct($client, $response);
151
152
        $this->id = $this->getResponseValue('id');
153
        $this->language = $this->getResponseValue('language');
154
        $this->mediaUri = $this->getResponseValue('media_uri');
155
        $this->state = $this->getResponseValue('state');
156
        $this->targetUri = $this->getResponseValue('target_uri');
157
    }
158
159
}
160