Completed
Push — 1.0 ( fb098d...df18cb )
by Valentin
03:59
created

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