Completed
Push — master ( 4762fe...4246d1 )
by
unknown
01:30
created

Account::exists()   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 2
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 exists($phone = null, $email = null)
0 ignored issues
show
Unused Code introduced by
The parameter $phone is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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