Passed
Push — master ( c8e4bc...17399e )
by Jacobo
04:15
created

PublishStreamBuilder::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 12
rs 9.9666
1
<?php
2
3
namespace SquareetLabs\LaravelOpenVidu\Builders;
4
5
use SquareetLabs\LaravelOpenVidu\Exceptions\OpenViduStreamTypeInvalidException;
6
use SquareetLabs\LaravelOpenVidu\IPCameraOptions;
7
use SquareetLabs\LaravelOpenVidu\StreamInterface;
8
9
/**
10
 * Class PublishStreamBuilder
11
 * @package SquareetLabs\LaravelOpenVidu\Builders
12
 */
13
class PublishStreamBuilder implements BuilderInterface
14
{
15
    /**
16
     * @param  array  $properties
17
     * @return StreamInterface
18
     * @throws OpenViduStreamTypeInvalidException
19
     */
20
    public static function build(array $properties)
21
    {
22
        switch ($properties['type']) {
23
            case 'IPCAM':
24
                return new IPCameraOptions($properties['rtspUri'],
25
                    $properties['type'],
26
                    $properties['adaptativeBitrate'],
27
                    $properties['onlyPlayWithSubscribers'],
28
                    $properties['data']
29
                );
30
            default:
31
                throw new OpenViduStreamTypeInvalidException();
32
        }
33
    }
34
}