Metadata   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B update() 0 20 5
1
<?php
2
3
namespace Clarify;
4
5
use Clarify\Exceptions\InvalidJSONException;
6
7
/**
8
 * Class Metadata
9
 * @package Clarify
10
 */
11
class Metadata extends Subresource
12
{
13
    protected $subresource = 'clarify:metadata';
14
15
    /**
16
     * @param array $options
17
     * @return mixed
18
     * @throws Exceptions\InvalidJSONException
19
     * @throws InvalidIntegerArgumentException
20
     */
21
    public function update(array $options)
22
    {
23
        $data = isset($options['data']) ? $options['data'] : '';
24
        $ob = json_decode($data);
25
        if($data != '' && $ob === null) {
26
            throw new InvalidJSONException();
27
        }
28
29
        $params = array();
30
        $params['data'] = $data;
31
        if (isset($options['version'])) {
32
            $params['version'] = (int) $options['version'];
33
        }
34
        $resourceURI = $this->getSubresourceURI($options['id']);
35
36
        $result = $this->client->put($resourceURI, $params);
37
        $this->detail = $this->client->detail;
38
39
        return $result;
40
    }
41
}
42