| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | public function incrementQueryFromSendGrid($notification) |
||
| 21 | { |
||
| 22 | $cols = ['hash', 'id_email', 'email', 'smtp-id', 'category', 'url', 'ip', 'useragent', 'clicks']; |
||
| 23 | /** @var Insert $query */ |
||
| 24 | $query = $this->newQuery('insert'); |
||
|
|
|||
| 25 | $query->setCols($cols); |
||
| 26 | |||
| 27 | $notification['hash'] = sha1($notification['id_email'] . $notification['email'] . $notification['url']); |
||
| 28 | $values = []; |
||
| 29 | foreach ($cols as $col) { |
||
| 30 | $values[$col] = $notification[$col]; |
||
| 31 | } |
||
| 32 | $values['clicks'] = 1; |
||
| 33 | $query->data($values); |
||
| 34 | $onDuplicate = ['clicks' => ['`clicks`+1', false]]; |
||
| 35 | $query->onDuplicate($onDuplicate); |
||
| 36 | |||
| 37 | return $query; |
||
| 38 | } |
||
| 40 |