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

RecordFileField::data()   B

Complexity

Conditions 7
Paths 8

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 8.2222
cc 7
eloc 9
nc 8
nop 1
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
}