Completed
Push — master ( 15515b...fd48c6 )
by Mike
02:14
created

RecordFileField   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B data() 0 13 7
1
<?php
2
3
namespace SugarAPI\SDK\EntryPoint\POST;
4
5
use SugarAPI\SDK\EntryPoint\Abstracts\POST\FileEntryPoint as POSTFileEntryPoint;
6
7
class RecordFileField extends POSTFileEntryPoint {
8
9
    protected $_URL = '$module/$record/file/$field';
10
11
    /**
12
     * @inheritdoc
13
     */
14
    protected $_REQUIRED_DATA = array(
15
        'format',
16
        'delete_if_fails',
17
        'oauth_token'
18
    );
19
20
    /**
21
     * @inheritdoc
22
     */
23
    public function data(array $data) {
24
        foreach($data as $key => $value){
25
            if (strtolower($key)!=='oauth_token' || strtolower($key)!=='delete_if_fails' || strtolower($key)!=='format'){
26
                if (strpos($value,'@')===FALSE){
27
                    $data[$key] = '@'.$value;
28
                }
29
            }
30
        }
31
        $data['oauth_token'] = $this->accessToken;
32
        $data['delete_if_fails'] = (isset($data['delete_if_fails'])?$data['delete_if_fails']:true);
33
        $data['format'] = 'sugar-html-json';
34
        return parent::data($data);
35
    }
36
37
}