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

UserGroupObject::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
ccs 12
cts 12
cp 1
rs 9.2
cc 4
eloc 8
nc 8
nop 2
crap 4
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
16
** Available keys: **
17
18
    $data = [
19
        remote_id               => string
20
        parent_id               => int      // Defaults to 12
21
        main_language_code      => string   // Defaults to eng-GB
22
        content_type_identifier => string   // Defaults to user_group
23
        fields                  => array [field definition identifier => value]
24
    ],
25
    $properties = [
26
        id                      => int (same as contentInfo->id)
27
        content_info            => \eZ\Publish\API\Repository\Values\Content\ContentInfo
28
        version_info            => \eZ\Publish\API\Repository\Values\Content\VersionInfo
29
        action                  => int {@link see \Transfer\EzPlatform\Data\Action\Enum\Action}
30
    ]
31
32
33
** Required on `create`:
34
**** Required by transfer:
35
    Fields in `fields` marked as required by ContentType
36
37
**** Required by eZ:
38
    parent_id
39
    content_type_identifier
40
    language
41
    Atleast one field defined in Fields
42
43
44
** Required on `update`:
45
**** Required by transfer:
46
    `id`
47
    Same as Content except for the defaults above
48
49
**** Required by eZ:
50
    id
51
    Same as Content except for the defaults above
52
53
*/
54
55
/**
56
 * User Group object.
57
 */
58
class UserGroupObject extends EzPlatformObject
59
{
60
    /**
61
     * @var UserGroupMapper
62
     */
63
    private $mapper;
64
65
    /**
66
     * UserGroupObject constructor.
67
     *
68
     * @param mixed $data
69
     * @param array $properties
70
     */
71 16
    public function __construct(array $data, array $properties = array())
72
    {
73 16
        if (!isset($data['parent_id'])) {
74 9
            $data['parent_id'] = 12;
75 9
        }
76 16
        if (!isset($data['main_language_code'])) {
77 2
            $data['main_language_code'] = 'eng-GB';
78 2
        }
79 16
        if (!isset($data['content_type_identifier'])) {
80 2
            $data['content_type_identifier'] = 'user_group';
81 2
        }
82 16
        parent::__construct($data, $properties);
83 16
    }
84
85
    /**
86
     * @return UserGroupMapper
87
     */
88 16
    public function getMapper()
89
    {
90 16
        if (!$this->mapper) {
91 16
            $this->mapper = new UserGroupMapper($this);
92 16
        }
93
94 16
        return $this->mapper;
95
    }
96
}
97