| Total Complexity | 4 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class InteractionRepository extends AbstractRepository |
||
| 12 | { |
||
| 13 | use ByCurrentUser; |
||
| 14 | |||
| 15 | public function getModelClass(): string |
||
| 16 | { |
||
| 17 | return Interaction::class; |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Get all songs favorited by a user. |
||
| 22 | */ |
||
| 23 | public function getUserFavorites(User $user): Collection |
||
| 24 | { |
||
| 25 | return $this->model->where([ |
||
| 26 | 'user_id' => $user->id, |
||
| 27 | 'liked' => true, |
||
| 28 | ]) |
||
| 29 | ->with('song') |
||
| 30 | ->get() |
||
| 31 | ->pluck('song'); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return Interaction[] |
||
| 36 | */ |
||
| 37 | public function getRecentlyPlayed(User $user, ?int $count = null): array |
||
| 53 | } |
||
| 54 | } |
||
| 55 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
integervalues, zero is a special case, in particular the following results might be unexpected: