Completed
Push — master ( df6768...08ae01 )
by Fèvre
11:28 queued 02:11
created

PermissionRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 1
A update() 0 7 1
1
<?php
2
namespace Xetaravel\Models\Repositories;
3
4
use Illuminate\Support\Facades\Hash;
5
use Illuminate\Support\Facades\Request as FacadeRequest;
6
use Xetaravel\Models\Permission;
7
8
class PermissionRepository
9
{
10
    /**
11
     * Create a new permission instance.
12
     *
13
     * @param array $data The data used to create the permission.
14
     *
15
     * @return \Xetaravel\Models\Permission
16
     */
17
    public static function create(array $data): Permission
18
    {
19
        return Permission::create([
20
            'name' => $data['name'],
21
            'description' => $data['description']
22
        ]);
23
    }
24
25
    /**
26
     * Update the permission informations after a valid update request.
27
     *
28
     * @param array $data The data used to update the permission.
29
     * @param \Xetaravel\Models\Permission $permission The permission to update.
30
     *
31
     * @return bool
32
     */
33
    public static function update(array $data, Permission $permission): bool
34
    {
35
        $permission->name = $data['name'];
36
        $permission->description = $data['description'];
37
38
        return $permission->save();
39
    }
40
}
41