Issues (3)

src/Traits/Encryptable.php (1 issue)

Severity
1
<?php
2
3
namespace tbclla\Revolut\Traits;
4
5
trait Encryptable
6
{
7
    /**
8
     * Set the value attribute
9
     *
10
     * @param string $value
11
     * @return void
12
     */
13
    public function setValueAttribute(string $value)
14
    {
15
        $encrypt = config('revolut.tokens.encrypt', true);
16
        
17
        $this->attributes['value'] = $encrypt ? encrypt($value) : $value;
0 ignored issues
show
Bug Best Practice introduced by
The property attributes does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
18
        $this->attributes['is_encrypted'] = $encrypt;
19
    }
20
21
    /**
22
     * Get the value attribute.
23
     * 
24
     * @param string|null $value
25
     * @return string
26
     */
27
    public function getValueAttribute($value)
28
    {
29
        return (string) $this->is_encrypted ? decrypt($value) : $value;
30
    }
31
}
32