Completed
Push — master ( 852cbb...117aa5 )
by diego
05:27
created

HashPassword::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace HDNET\Importr\Feature;
3
4
use HDNET\Importr\Processor\Target;
5
use HDNET\Importr\Service\PasswordHashService;
6
7
/**
8
 * Class HashPassword.
9
 */
10
class HashPassword
11
{
12
    /**
13
     * @var PasswordHashService
14
     */
15
    protected $hashService;
16
17
    /**
18
     * RenameFile constructor.
19
     *
20
     * @param PasswordHashService $hashService
21
     */
22 1
    public function __construct(PasswordHashService $hashService)
23
    {
24 1
        $this->hashService = $hashService;
25 1
    }
26
27
    /**
28
     * @return void
29
     */
30 1
    public static function enable()
31
    {
32 1
        FeatureRegistry::enable('preProcess', Target::class);
33 1
    }
34
35
    /**
36
     * @param array $configuration
37
     * @param array $entry
38
     *
39
     * @return array
40
     */
41
    public function execute(array $configuration, array $entry)
42
    {
43
        if (isset($configuration['filter']['password']) && in_array($configuration['filter']['password'], $configuration['mapping'])) {
44
            $field = array_search($configuration['filter']['password'], $configuration['mapping']);
45
            $entry[$field] = $this->hashService->hash($entry[$field]);
46
        }
47
48
        return [$configuration, $entry];
49
    }
50
}