ConnectRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getModelName() 0 4 1
A forUser() 0 15 2
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
}