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

UserGroupObject   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 7
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 49
ccs 20
cts 20
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 4
A getMapper() 0 8 2
A setStructCallback() 0 4 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