MappingLogRepository::find()   A
last analyzed

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
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Triadev\Leopard\Business\Repository;
3
4
use Illuminate\Support\Facades\DB;
5
use Triadev\Leopard\Contract\Repository\MappingLogRepositoryContract;
6
use Triadev\Leopard\Model\Entity\MappingLog;
7
8
class MappingLogRepository implements MappingLogRepositoryContract
9
{
10
    /**
11
     * @inheritdoc
12
     */
13 15
    public function add(string $mapping)
14
    {
15 15
        $entity = new MappingLog();
16
        
17 15
        $entity->mapping = $mapping;
18 15
        $entity->saveOrFail();
19 15
    }
20
    
21
    /**
22
     * @inheritdoc
23
     */
24 3
    public function find(int $id) : ?MappingLog
25
    {
26 3
        return MappingLog::find($id);
27
    }
28
    
29
    /**
30
     * @inheritdoc
31
     */
32 3
    public function delete(int $id)
33
    {
34 3
        if ($mappingLog = $this->find($id)) {
35 1
            $mappingLog->delete();
36
        }
37 3
    }
38
    
39
    /**
40
     * @inheritdoc
41
     */
42 15
    public function all(): array
43
    {
44 15
        return MappingLog::all(['id', 'mapping'])->toArray();
45
    }
46
    
47
    /**
48
     * @inheritdoc
49
     */
50 3
    public function reset()
51
    {
52 3
        DB::table('triadev_mapping_log')->truncate();
53 3
    }
54
}
55