Completed
Push — master ( 67ffdb...cdd3ba )
by Ashleigh
01:33
created

Account::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
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
    public function create(array $params)
13
    {
14
        $params['RecordTypeId'] = config('laravel-salesforce.record_type.account');
15
16
        return parent::create($params);
17
    }
18
19
    /**
20
     * Check if account already exists on SF.
21
     *
22
     * @param string $email
23
     *
24
     * @return bool|array
25
     */
26
    public function checkAlreadyExists($email)
27
    {
28
        $query = 'SELECT Id, OwnerId  FROM '.$this->getType().' WHERE PersonEmail = \''.addslashes(trim($email)).'\' AND RecordTypeId = \''.config('laravel-salesforce.record_type.account').'\'';
29
30
        $response = $this->query($query);
31
32
        if ($response && $response->totalSize > 0) {
33
            return array_shift($response->records);
34
        }
35
36
        return false;
37
    }
38
}
39