Passed
Push — master ( e93faf...0a06f9 )
by Nicolaas
02:13
created

SalesforceTest::updateContact()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
4
use SForce\Client\Partner;
5
6
use SForce\SObject;
7
8
use SForce\Wsdl\create;
9
10
class SalesforceTest extends BuildTask
11
{
12
    protected $title = 'Test Sales Force API';
13
14
    protected $description = 'Test Sales Cloud';
15
16
    protected $emailStub = '@test.best.co.com.org.net';
17
18
    protected $email = '';
19
20
    public function run($request)
21
    {
22
        MySalesforceContactApi::set_debug(true);
23
        $this->setEmail();
24
        $this->findContact();
25
        $this->createContact();
26
        $this->updateContact();
27
        $this->setEmail();
28
        $this->createBadContact();
29
    }
30
31
    protected function createContact()
32
    {
33
        MySalesforceContactApi::create_contact(
34
            [
35
                'FirstName' => 'John',
36
                'LastName' => 'Smith',
37
                'Phone' => '(510) 555-5555',
38
                'Email' => $this->email,
39
            ]
40
        );
41
    }
42
43
    protected function updateContact()
44
    {
45
        MySalesforceContactApi::update_contact(
46
            [
47
                'FirstName' => 'Joan',
48
                'LastName' => 'Smith',
49
                'Phone' => '(510) 555-5555',
50
                'Email' => $this->email,
51
            ]
52
        );
53
    }
54
55
    protected function findContact()
56
    {
57
        $contact = MySalesforceContactApi::retrieve_contact($this->email);
0 ignored issues
show
Bug introduced by
$this->email of type string is incompatible with the type array expected by parameter $fieldsArray of MySalesforceContactApi::retrieve_contact(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

57
        $contact = MySalesforceContactApi::retrieve_contact(/** @scrutinizer ignore-type */ $this->email);
Loading history...
Unused Code introduced by
The assignment to $contact is dead and can be removed.
Loading history...
58
    }
59
60
61
    protected function createBadContact()
62
    {
63
        MySalesforceContactApi::create_contact(
64
            [
65
                'FirstName' => 'John',
66
                'LastName' => 'Smith',
67
                'NON_EXISTING_FIELD' => 'RUBBISH',
68
                'Email' => $this->email,
69
            ]
70
        );
71
    }
72
73
74
    protected function setEmail()
75
    {
76
        $this->email = 'test'.rand(0,99999).$this->emailStub;
77
78
    }
79
80
}
81