Completed
Push — master ( 170553...63fad2 )
by Richard
01:12
created

AESEncrypted   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 4 1
A set() 0 4 1
1
<?php
2
3
namespace RichardStyles\EloquentAES\Casts;
4
5
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
6
use RichardStyles\EloquentAES\EloquentAESFacade as EloquentAES;
7
8
class AESEncrypted implements CastsAttributes
9
{
10
    /**
11
     * Cast the given value and decrypt
12
     *
13
     * @param  \Illuminate\Database\Eloquent\Model  $model
14
     * @param  string  $key
15
     * @param  mixed  $value
16
     * @param  array  $attributes
17
     * @return array
18
     */
19
    public function get($model, $key, $value, $attributes)
20
    {
21
        return EloquentAES::decrypt($value);
22
    }
23
24
    /**
25
     * Prepare the given value for storage.
26
     *
27
     * @param  \Illuminate\Database\Eloquent\Model  $model
28
     * @param  string  $key
29
     * @param  mixed  $value
30
     * @param  array  $attributes
31
     * @return string
32
     */
33
    public function set($model, $key, $value, $attributes)
34
    {
35
        return EloquentAES::encrypt($value);
36
    }
37
}