Conditions | 6 |
Paths | 5 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
27 | public function exists($phone = null, $email = null) |
||
28 | { |
||
29 | //return false if not enough data provided |
||
30 | if ($email === null && $phone === null) { |
||
31 | return false; |
||
32 | } |
||
33 | |||
34 | if ($email !== null) { |
||
35 | $query = 'SELECT Id, OwnerId FROM ' . $this->getType() . ' WHERE Email = \'' . addslashes(trim($email)) . '\''; |
||
36 | } else { |
||
37 | $query = 'SELECT Id, OwnerId FROM ' . $this->getType() . ' WHERE Phone = \'' . addslashes(trim($phone)) . '\''; |
||
38 | } |
||
39 | |||
40 | $query .= ' AND RecordTypeId = \'' . config('laravel-salesforce.record_type.lead') . '\''; |
||
41 | |||
42 | $response = $this->query($query); |
||
43 | |||
44 | if ($response && $response->totalSize > 0) { |
||
45 | return array_shift($response->records); |
||
46 | } |
||
47 | |||
48 | return false; |
||
49 | } |
||
50 | } |
||
51 |