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

GameModRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 1
crap 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