Completed
Push — master ( fd48c6...d6eea8 )
by Mike
02:42
created

Oauth2Token::configureData()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 8
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
1
<?php
2
3
namespace SugarAPI\SDK\EntryPoint\POST;
4
5
use SugarAPI\SDK\EntryPoint\Abstracts\POST\JSONEntryPoint as POSTEntryPoint;
6
7
class Oauth2Token extends POSTEntryPoint {
8
9
    protected $_AUTH_REQUIRED = false;
10
    protected $_URL = 'oauth2/token';
11
    protected $_REQUIRED_DATA = array(
12
        'username',
13
        'password',
14
        'grant_type',
15
        'client_id',
16
        'client_secret',
17
        'platform'
18
    );
19
20
    /**
21
     * Configure the Grant Type to be Password
22
     * @param mixed $data
23
     * @return array|mixed
24
     */
25
    protected function configureData($data) {
26
        if (is_array($data)){
27
            $data['grant_type'] = 'password';
28
        }elseif (is_object($data)){
29
            $data->grant_type = 'password';
30
        }
31
        return $data;
32
    }
33
34
35
}