GroupRepository   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getModelName() 0 4 1
A get() 0 18 3
1
<?php
2
3
namespace App\Repositories;
4
5
use App\Exceptions\RepositoryException;
6
use Exception;
7
8
class GroupRepository extends Repository {
9
10
    public function getModelName()
11
    {
12
        return 'App\Models\Groups';
13
    }
14
15
    public function get($groupId=-1)
16
    {
17
        if( $groupId==-1 ) {
18
            $groupId = session('groupID');
19
        }
20
        else {
21
            $this->validateID($groupId);
22
        }
23
24
        try {
25
            $group = $this->model->findOrFail($groupId);
26
        }
27
        catch(Exception $e) {
28
            throw new RepositoryException('Could not find group with ID '.$groupId, RepositoryException::DATABASE_ERROR);
29
        }
30
31
        return $group;
32
    }
33
34
}