ConnectRepository::forUser()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
3
namespace App\Repositories;
4
5
use App\Exceptions\RepositoryException;
6
7
class ConnectRepository extends Repository {
8
9
    public function getModelName()
10
    {
11
        return 'App\Models\ConnectHistory';
12
    }
13
14
    public function forUser($userId)
15
    {
16
        $this->validateID($userId);
17
18
        try
19
        {
20
            $connections = $this->model->where('user_id', '=', $userId)->orderBy('connect_time', 'DESC')->get();
21
        }
22
        catch(\Exception $e)
23
        {
24
            throw new RepositoryException('Could not fetch connections for user #'.$userId, RepositoryException::DATABASE_ERROR);
25
        }
26
27
        return $connections;
28
    }
29
30
}