Tracks::create()   B
last analyzed

Complexity

Conditions 5
Paths 16

Size

Total Lines 17
Code Lines 12

Duplication

Lines 3
Ratio 17.65 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 5
eloc 12
c 4
b 0
f 0
nc 16
nop 1
dl 3
loc 17
rs 8.8571
1
<?php
2
3
namespace Clarify;
4
5
use Clarify\Exceptions\InvalidEnumTypeException;
6
7
/**
8
 * Class Tracks
9
 * @package Clarify
10
 */
11
class Tracks extends Subresource
12
{
13
    protected $subresource = 'clarify:tracks';
14
15
    /**
16
     * @param array $options
17
     * @return \Guzzle\Http\Message\Response|null
18
     * @throws InvalidEnumTypeException
19
     */
20
    public function create(array $options)
21
    {
22
        $params = array();
23
        $params['media_url'] = $options['media_url'];
24
        $params['label'] = isset($options['label']) ? $options['label'] : '';
25
        $params['source'] = isset($options['source']) ? $options['source'] : '';
26
        $params['audio_channel'] = isset($options['audio_channel']) ? $options['audio_channel'] : '';
27 View Code Duplication
        if (!in_array($params['audio_channel'], array('left', 'right', 'split', ''))) {
28
            throw new InvalidEnumTypeException();
29
        }
30
31
        $resourceURI = $this->getSubresourceURI($options['id']);
32
        $result = $this->client->post($resourceURI, $params);
33
        $this->detail = $this->client->detail;
34
35
        return $result;
36
    }
37
}
38