EncryptableFieldEntity   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 26
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A encryptField() 0 6 1
A verifyEncryptedFieldValue() 0 5 1
1
<?php
2
3
namespace OAuth\Traits;
4
5
use Zend\Crypt\Password\Bcrypt;
6
7
trait EncryptableFieldEntity
8
{
9
    private $bcrypt;
10
11
    /**
12
     * @param $value
13
     * @return bool|string
14
     */
15
    protected function encryptField($value)
16
    {
17
        $this->bcrypt = new Bcrypt();
18
        $this->bcrypt->setCost(14);
19
        $encryptedPassword = $this->bcrypt->create($value);
20
        return $encryptedPassword;
21
    }
22
23
    /**
24
     * @param $encryptedValue
25
     * @param $value
26
     * @return bool
27
     */
28
    protected function verifyEncryptedFieldValue($encryptedValue, $value)
29
    {
30
        $this->bcrypt = new Bcrypt();
31
        $this->bcrypt->setCost(14);
32
        return $this->bcrypt->verify($value, $encryptedValue);
33
    }
34
}