UserGroupObject::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 3
b 0
f 0
nc 4
nop 2
dl 0
loc 10
ccs 8
cts 8
cp 1
crap 3
rs 9.4285
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\UserGroupMapper;
13
14
/**
15
 * User Group object.
16
 *
17
 * @see http://transfer-framework.com/docs/1.0/sources_and_targets/ezplatform/the_objects/usergroupobject.html
18
 */
19
class UserGroupObject extends EzPlatformObject
20
{
21
    /**
22
     * @var UserGroupMapper
23
     */
24
    private $mapper;
25
26
    /**
27
     * UserGroupObject constructor.
28
     *
29
     * @param mixed $data
30
     * @param array $properties
31 20
     */
32
    public function __construct(array $data, array $properties = array())
33 20
    {
34 10
        if (!isset($data['parent_id'])) {
35 10
            $data['parent_id'] = 12;
36 20
        }
37 2
        if (!isset($data['content_type_identifier'])) {
38 2
            $data['content_type_identifier'] = 'user_group';
39 20
        }
40 20
        parent::__construct($data, $properties);
41
    }
42
43
    /**
44
     * @return UserGroupMapper
45 20
     */
46
    public function getMapper()
47 20
    {
48 20
        if (!$this->mapper) {
49 20
            $this->mapper = new UserGroupMapper($this);
50
        }
51 20
52
        return $this->mapper;
53
    }
54
55
    /**
56
     * Allows direct control in UserGroupCreateStruct and UserGroupUpdateStruct.
57
     *
58
     * @param \Closure $callback
59 1
     */
60
    public function setStructCallback(\Closure $callback)
61 1
    {
62 1
        $this->setProperty('struct_callback', $callback);
63
    }
64
}
65