Completed
Push — 1.0 ( 2156a0...733517 )
by Valentin
07:09
created

UserObject   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 36
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 3
A getMapper() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of Transfer.
5
 *
6
 * For the full copyright and license information, please view the LICENSE file located
7
 * in the root directory.
8
 */
9
10
namespace Transfer\EzPlatform\Repository\Values;
11
12
use Transfer\EzPlatform\Repository\Values\Mapper\UserMapper;
13
14
/*
15
16
** Available keys: **
17
18
    $parents = Transfer\EzPlatform\Data\UserGroupObject[]
19
    $data = [
20
        username => string
21
        email => string
22
        password => string
23
        main_language_code => string
24
        enabled => bool
25
        max_login => int
26
        fields => [ first_name => string
27
                    last_name => string
28
                    ...                 ]
29
    ],
30
    $properties = [
31
        action => int {@link see \Transfer\EzPlatform\Data\Action\Enum\Action}
32
    ]
33
34
35
** Required on `create`:
36
**** Required by transfer:
37
    `username´
38
    `email`
39
    `password`
40
41
**** Required by eZ:
42
    `username´
43
    `èmail`
44
    `password`
45
    `main_language_code`
46
    And any required fields in `fields`
47
48
** Required on `update`:
49
**** Required by transfer:
50
    `username`
51
52
**** Required by eZ:
53
    `username`
54
55
*/
56
57
/**
58
 * User object.
59
 */
60
class UserObject extends EzPlatformObject
61
{
62
    /**
63
     * @var UserGroupObject[]
64
     */
65
    public $parents;
66
67
    /**
68
     * @var UserMapper
69
     */
70
    protected $mapper;
71
72 8
    public function __construct(array $data, array $properties = array())
73
    {
74 8
        if (isset($data['parents'])) {
75 7
            $this->parents = $data['parents'];
76 7
            unset($data['parents']);
77 7
        }
78
79 8
        $data['max_login'] = isset($data['max_login']) ? $data['max_login'] : null;
80
81 8
        parent::__construct($data, $properties);
82 8
    }
83
84
    /**
85
     * @return UserMapper
86
     */
87 7
    public function getMapper()
88
    {
89 7
        if (!$this->mapper) {
90 7
            $this->mapper = new UserMapper($this);
91 7
        }
92
93 7
        return $this->mapper;
94
    }
95
}
96