LocationObject   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 44
ccs 16
cts 16
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A setStructCallback() 0 4 1
A getMapper() 0 8 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;
11
12
use eZ\Publish\API\Repository\Values\Content\Location;
13
use Transfer\EzPlatform\Repository\Values\Mapper\LocationMapper;
14
15
/**
16
 * Location object.
17
 *
18
 * @see http://transfer-framework.com/docs/1.0/sources_and_targets/ezplatform/the_objects/locationobject.html
19
 */
20
class LocationObject extends EzPlatformObject
21
{
22
    /**
23
     * @var LocationMapper
24
     */
25
    private $mapper;
26
27
    /**
28
     * LocationObject constructor.
29
     *
30
     * @param array|Location $data
31
     * @param array          $properties
32 20
     */
33
    public function __construct($data, array $properties = [])
34 20
    {
35 1
        if ($data instanceof Location) {
36 1
            $this->getMapper()->locationToObject($data);
37 20
        } else {
38 1
            parent::__construct($data, $properties);
39 20
        }
40
    }
41
42
    /**
43
     * Allows direct control in LocationCreateStruct and LocationUpdateStruct.
44
     *
45
     * @param \Closure $callback
46 2
     */
47 1
    public function setStructCallback(\Closure $callback)
48 2
    {
49 2
        $this->setProperty('struct_callback', $callback);
50
    }
51
52
    /**
53
     * @return LocationMapper
54 19
     */
55
    public function getMapper()
56 19
    {
57 19
        if (!$this->mapper) {
58 19
            $this->mapper = new LocationMapper($this);
59
        }
60 19
61
        return $this->mapper;
62
    }
63
}
64