Password   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 60
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A _construct() 0 4 1
A getDataModel() 0 14 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * File:Password.php
6
 *
7
 * @author Maciej Sławik <[email protected]>
8
 * @copyright Copyright (C) 2018 Lizard Media (http://lizardmedia.pl)
9
 */
10
11
namespace LizardMedia\PasswordMigrator\Model;
12
13
use Magento\Framework\Data\Collection\AbstractDb;
14
use Magento\Framework\Model\AbstractModel;
15
use LizardMedia\PasswordMigrator\Api\Data\PasswordInterface;
16
use LizardMedia\PasswordMigrator\Api\Data\PasswordInterfaceFactory;
17
use Magento\Framework\Registry;
18
use Magento\Framework\Model\ResourceModel\AbstractResource;
19
use Magento\Framework\Model\Context;
20
use LizardMedia\PasswordMigrator\Model\ResourceModel\Password as PasswordResource;
21
22
/**
23
 * Class Password
24
 * @package LizardMedia\PasswordMigrator\Model
25
 */
26
class Password extends AbstractModel
27
{
28
    const ID = 'id';
29
    const CUSTOMER_ID = 'customer_id';
30
    const PASSWORD = 'password';
31
    const SALT = 'salt';
32
    const CREATED_AT = 'created_at';
33
34
    /**
35
     * @var PasswordInterfaceFactory
36
     */
37
    private $passwordFactory;
38
39
    /**
40
     * Password constructor.
41
     * @param PasswordInterfaceFactory $passwordFactory
42
     * @param Context $context
43
     * @param Registry $registry
44
     * @param AbstractResource|null $resource
45
     * @param AbstractDb|null $resourceCollection
46
     * @param array $data
47
     */
48
    public function __construct(
49
        PasswordInterfaceFactory $passwordFactory,
50
        Context $context,
51
        Registry $registry,
52
        AbstractResource $resource = null,
53
        AbstractDb $resourceCollection = null,
54
        array $data = []
55
    ) {
56
        parent::__construct($context, $registry, $resource, $resourceCollection, $data);
57
        $this->passwordFactory = $passwordFactory;
58
    }
59
60
    /**
61
     * @return void
62
     */
63
    protected function _construct()
64
    {
65
        $this->_init(PasswordResource::class);
66
    }
67
68
    /**
69
     * @return PasswordInterface
70
     */
71
    public function getDataModel(): PasswordInterface
72
    {
73
        /** @var PasswordInterface $passwordDTO */
74
        $passwordDTO = $this->passwordFactory->create(
75
            [
76
                'id' => $this->getData(self::ID),
77
                'customerId' => $this->getData(self::CUSTOMER_ID)
78
            ]
79
        );
80
        $passwordDTO->setPassword($this->getData(self::PASSWORD));
81
        $passwordDTO->setSalt($this->getData(self::SALT));
82
        $passwordDTO->setCreatedAt($this->getData(self::CREATED_AT));
83
        return $passwordDTO;
84
    }
85
}
86