Tracks   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 11.11 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 5
c 4
b 0
f 0
lcom 1
cbo 3
dl 3
loc 27
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B create() 3 17 5

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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