GroupRepository::get()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 3
eloc 10
nc 4
nop 1
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
}