SugarAPI   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 8
Bugs 3 Features 0
Metric Value
wmc 3
c 8
b 3
f 0
lcom 1
cbo 1
dl 0
loc 28
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setCredentials() 0 8 3
1
<?php
2
/**
3
 * ©[2016] SugarCRM Inc.  Licensed by SugarCRM under the Apache 2.0 license.
4
 */
5
6
namespace SugarAPI\SDK;
7
8
use SugarAPI\SDK\Client\Abstracts\AbstractClient;
9
use SugarAPI\SDK\EntryPoint\Interfaces\EPInterface;
10
11
/**
12
 * The default SDK Client Implemntation
13
 * @package SugarAPI\SDK
14
 * @method EPInterface ping()
15
 * @method EPInterface getRecord(string $module = '')
16
 * @method EPInterface getAttachment(string $module = '',string $record_id = '')
17
 * @method EPInterface getChangeLog(string $module = '',string $record_id = '')
18
 * @method EPInterface filterRelated(string $module = '')
19
 * @method EPInterface getRelated(string $module = '',string $record_id = '',string $relationship = '',string $related_id = '')
20
 * @method EPInterface me()
21
 * @method EPInterface search()
22
 * @method EPInterface oauth2Token()
23
 * @method EPInterface oauth2Refresh()
24
 * @method EPInterface createRecord()
25
 * @method EPInterface filterRecords()
26
 * @method EPInterface attachFile()
27
 * @method EPInterface oauth2Logout()
28
 * @method EPInterface createRelated()
29
 * @method EPInterface linkRecords()
30
 * @method EPInterface bulk()
31
 * @method EPInterface updateRecord()
32
 * @method EPInterface favorite()
33
 * @method EPInterface deleteRecord()
34
 * @method EPInterface unfavorite()
35
 * @method EPInterface deleteFile()
36
 * @method EPInterface unlinkRecords()
37
 */
38
class SugarAPI extends AbstractClient {
39
40
    /**
41
     * The configured Authentication options
42
     * @var array
43
     */
44
    protected $credentials = array(
45
        'username' => '',
46
        'password' => '',
47
        'client_id' => 'sugar',
48
        'client_secret' => '',
49
        'platform' => 'api'
50
    );
51
52
    /**
53
     * @inheritdoc
54
     * Overrides only the credentials properties passed in, instead of entire credentials array
55
     */
56 1
    public function setCredentials(array $credentials){
57 1
        foreach ($this->credentials as $key => $value){
58 1
            if (isset($credentials[$key])){
59 1
                $this->credentials[$key] = $credentials[$key];
60 1
            }
61 1
        }
62 1
        return parent::setCredentials($this->credentials);
63
    }
64
65
}