| Conditions | 6 |
| Paths | 5 |
| Total Lines | 23 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | public function checkAlreadyExists($phone = null, $email = null) |
||
| 28 | { |
||
| 29 | //return false if not enough data provided |
||
| 30 | if (!$email && !$phone) { |
||
| 31 | return false; |
||
| 32 | } |
||
| 33 | |||
| 34 | if ($email) { |
||
| 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 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: