Completed
Push — master ( f64d24...b2dcac )
by Jasper
04:10
created

EncryptedCast   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 10
ccs 4
cts 4
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 2
A set() 0 3 2
1
<?php
2
3
namespace Swis\Laravel\Encrypted;
4
5
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
6
7
class EncryptedCast implements CastsAttributes
8
{
9 6
    public function get($model, string $key, $value, array $attributes)
10
    {
11 6
        return $value === null ? null : decrypt($value);
12
    }
13
14 6
    public function set($model, string $key, $value, array $attributes)
15
    {
16 6
        return $value === null ? null : encrypt($value);
17
    }
18
}
19