Passed
Push — develop ( 440a15...e4ddd7 )
by Nikita
09:36
created

GameModRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 30%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 27
ccs 3
cts 10
cp 0.3
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getAll() 0 3 1
A getIdNameListForGame() 0 6 1
A getById() 0 3 1
1
<?php
2
3
namespace Gameap\Repositories;
4
5
use Gameap\Models\GameMod;
6
7
class GameModRepository extends Repository
8
{
9 9
    public function __construct(GameMod $gameMod)
10
    {
11 9
        $this->model = $gameMod;
12 9
    }
13
14
    public function getAll($perPage = 20)
15
    {
16
        return GameMod::orderBy('id')->paginate($perPage);
17
    }
18
19
    public function getById(int $id): GameMod
20
    {
21
        return GameMod::findOrFail($id);
22
    }
23
24
    /**
25
     * @param string $gameCode
26
     * @return array
27
     */
28
    public function getIdNameListForGame(string $gameCode)
29
    {
30
        return $this->model->select('id', 'name')
31
            ->where('game_code', '=', $gameCode)
32
            ->orderBy('name')
33
            ->get();
34
    }
35
}
36