| Conditions | 3 |
| Paths | 4 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 3.0987 |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | 2 | public function forget(string $key, string $value = null): bool |
|
| 49 | { |
||
| 50 | // Delete interest |
||
| 51 | 2 | $delete = Interest::where('key', $key); |
|
| 52 | |||
| 53 | 2 | if (isset($value)) { |
|
| 54 | // Only delete this token |
||
| 55 | $delete->where('value', $value); |
||
| 56 | } |
||
| 57 | |||
| 58 | 2 | $delete->delete(); |
|
| 59 | |||
| 60 | // Check if our interest exist |
||
| 61 | 2 | $count = Interest::where('key', $key); |
|
| 62 | |||
| 63 | 2 | if (isset($value)) { |
|
| 64 | $count->where('value', $value); |
||
| 65 | } |
||
| 66 | |||
| 67 | 2 | return $count->count() === 0; |
|
| 68 | } |
||
| 69 | } |
||
| 70 |