Completed
Push — master ( c551a7...63e8f9 )
by
unknown
03:14
created

DummyConnection::sendPayload()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 47
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 47
rs 8.5125
c 1
b 0
f 1
cc 5
eloc 37
nc 5
nop 1
1
<?php
2
3
namespace VideoPublisher\Tests\Dummy;
4
5
use VideoPublisher\Connection\ConnectionInterface;
6
use VideoPublisher\Connection\Curl\CurlResponse;
7
use VideoPublisher\Connection\ResponseInterface;
8
use VideoPublisher\Payload\Payload;
9
10
class DummyConnection implements ConnectionInterface
11
{
12
13
    /**
14
     * @param Payload $payload
15
     * @return ResponseInterface
16
     */
17
    public function sendPayload(Payload $payload)
18
    {
19
        switch ($payload->getUrl()) {
20
            case 'http://my.videopublisher.io/api/published':
21
                $streams = [];
22
                $streams[] = [
23
                    'streamName' => 'test',
24
                    'uuid' => '00000000-0000-0000-0000-00000000',
25
                    'status' => 'mock',
26
                    'enabled' => true
27
                ];
28
                $streams[] = [
29
                    'streamName' => 'test',
30
                    'uuid' => '00000000-0000-0000-0000-00000000',
31
                    'status' => 'mock',
32
                    'enabled' => true
33
                ];
34
                $streams[] = [
35
                    'streamName' => 'test',
36
                    'uuid' => '00000000-0000-0000-0000-00000000',
37
                    'status' => 'mock',
38
                    'enabled' => true
39
                ];
40
41
                return new CurlResponse(200, null, json_encode($streams));
42
            case 'http://my.videopublisher.io/api/publish/00000000-0000-0000-0000-00000000':
43
                $stream = [
44
                    'streamName' => 'test',
45
                    'uuid' => '00000000-0000-0000-0000-00000000',
46
                    'status' => 'mock',
47
                    'enabled' => true,
48
                    'viewable' => true,
49
                    'view' => [
50
                        'playout_url' => 'http://playout.com/video.mp4',
51
                        'video_player' => 'http://playout.com/player/video.mp4'
52
                    ]
53
                ];
54
                return new CurlResponse(200, null, json_encode($stream));
55
            case 'http://my.videopublisher.io/exception/api/published':
56
                return new CurlResponse(400, null, null);
57
            case 'http://my.videopublisher.io/exception/api/publish/00000000-0000-0000-0000-00000000':
58
                return new CurlResponse(400, null, null);
59
        }
60
61
        var_dump($payload->getUrl());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($payload->getUrl()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
62
        die;
0 ignored issues
show
Coding Style Compatibility introduced by
The method sendPayload() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
63
    }
64
}