Completed
Pull Request — 1.0 (#36)
by Valentin
46:37
created

UserObject::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.4285
cc 3
eloc 6
nc 4
nop 2
crap 3
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\Data;
11
12
use Transfer\Data\ValueObject;
13
use Transfer\EzPlatform\Repository\Content\UserMapper;
14
15
/**
16
 * User object.
17
 */
18
class UserObject extends ValueObject
19
{
20
    /**
21
     * @var UserGroupObject[]
22
     */
23
    public $parents;
24
25
    /**
26
     * @var UserMapper
27
     */
28
    protected $mapper;
29
30 9
    public function __construct(array $data, array $properties = array())
31
    {
32 9
        if (isset($data['parents'])) {
33 8
            $this->parents = $data['parents'];
34 8
            unset($data['parents']);
35 8
        }
36
37 9
        $data['max_login'] = isset($data['max_login']) ? $data['max_login'] : null;
38
39 9
        parent::__construct($data, $properties);
40 9
    }
41
42
    /**
43
     * @return UserMapper
44
     */
45 6
    public function getMapper()
46
    {
47 6
        if (!$this->mapper) {
48 6
            $this->mapper = new UserMapper($this);
49 6
        }
50
51 6
        return $this->mapper;
52
    }
53
}
54