Passed
Branch 1.0 (733517)
by Harald
06:28
created

ContentMapper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 29
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A contentToObject() 0 10 2
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\Mapper;
11
12
use eZ\Publish\API\Repository\Values\Content\Content;
13
use Transfer\EzPlatform\Repository\Values\ContentObject;
14
15
/**
16
 * User mapper.
17
 *
18
 * @author Harald Tollefsen <[email protected]>
19
 */
20
class ContentMapper
21
{
22
    /**
23
     * @var ContentObject
24
     */
25
    public $contentObject;
26
27
    /**
28
     * @param ContentObject $contentObject
29
     */
30 3
    public function __construct(ContentObject $contentObject)
31
    {
32 3
        $this->contentObject = $contentObject;
33 3
    }
34
35
    /**
36
     * @param Content $content
37
     */
38 3
    public function contentToObject(Content $content)
39
    {
40 3
        $this->contentObject->setProperty('id', $content->id);
41 3
        $this->contentObject->setProperty('remote_id', $content->contentInfo->remoteId);
42 3
        $this->contentObject->setProperty('content_info', $content->contentInfo);
43 3
        $this->contentObject->setProperty('version_info', $content->versionInfo);
44 3
        foreach ($content->getFields() as $field) {
45 3
            $this->contentObject->data[$field->fieldDefIdentifier][$field->languageCode] = $field->value;
46 3
        }
47 3
    }
48
}
49