Completed
Push — master ( abf85d...bf3287 )
by Ashleigh
04:27
created

Account::checkAlreadyExists()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace Surge\LaravelSalesforce\Objects;
4
5
class Account extends AbstractObject
6
{
7
    /**
8
     * Insert new account.
9
     *
10
     * @param $params
11
     *
12
     * @return bool
13
     */
14
    public function insert($params)
15
    {
16
        $params['RecordTypeId'] = config('laravel-salesforce.record_type.account');
17
18
        return $this->createRecord($this->getType(), $params);
0 ignored issues
show
Bug introduced by
The method createRecord() does not exist on Surge\LaravelSalesforce\Objects\Account. Did you maybe mean create()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
19
    }
20
21
    /**
22
     * Check if account already exists on SF.
23
     *
24
     * @param string $email
25
     *
26
     * @return bool|array
27
     */
28
    public function checkAlreadyExists($email)
29
    {
30
        $query = 'SELECT Id, OwnerId  FROM '.$this->getType().' WHERE PersonEmail = \''.addslashes(trim($email)).'\' AND RecordTypeId = \''.config('laravel-salesforce.record_type.account').'\'';
31
32
        $response = $this->query($query);
33
34
        if ($response && $response->totalSize > 0) {
35
            return array_shift($response->records);
36
        }
37
38
        return false;
39
    }
40
}
41