Completed
Push — master ( 5b54fc...16c96d )
by Bertrand
14:42
created

CharacteristicsRepositorySql::add()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
4
namespace App\Src\UseCases\Infra\Sql;
5
6
7
use App\Src\UseCases\Domain\Ports\CharacteristicsRepository;
8
use App\Src\UseCases\Infra\Sql\Model\CharacteristicsModel;
9
10
class CharacteristicsRepositorySql implements CharacteristicsRepository
11
{
12
    public function getByType(string $type, bool $isMain): array
13
    {
14
        $list = CharacteristicsModel::query()
15
            ->where('type', $type)
16
            ->where('main', $isMain)
17
            ->orderBy('priority')
18
            ->get();
19
        return $list->toArray();
20
    }
21
22
    /**
23
     * only used for ti test
24
     * @param array $cs
25
     */
26
    public function add(array $cs)
27
    {
28
        foreach ($cs as $c){
29
            $cModel = new CharacteristicsModel();
30
            $cModel->fill($c);
31
            $cModel->save();
32
        }
33
    }
34
}
35