Completed
Push — 7.0_master_link_manager_merge ( e446e3 )
by André
77:34 queued 60:56
created

URLService   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 84
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 4

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createUpdateStruct() 0 4 1
A findUrls() 0 4 1
A findUsages() 0 4 1
A loadById() 0 4 1
A loadByUrl() 0 4 1
A updateUrl() 0 12 1
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\SignalSlot;
8
9
use eZ\Publish\API\Repository\URLService as URLServiceInterface;
10
use eZ\Publish\API\Repository\Values\URL\URL;
11
use eZ\Publish\API\Repository\Values\URL\URLQuery;
12
use eZ\Publish\API\Repository\Values\URL\URLUpdateStruct;
13
use eZ\Publish\Core\SignalSlot\Signal\URLService\UpdateUrlSignal;
14
15
class URLService implements URLServiceInterface
16
{
17
    /**
18
     * Aggregated service.
19
     *
20
     * @var \eZ\Publish\API\Repository\URLService
21
     */
22
    protected $service;
23
24
    /**
25
     * SignalDispatcher.
26
     *
27
     * @var SignalDispatcher
28
     */
29
    protected $signalDispatcher;
30
31
    /**
32
     * URLService constructor.
33
     *
34
     * @param \eZ\Publish\API\Repository\URLService $service
35
     * @param \eZ\Publish\Core\SignalSlot\SignalDispatcher $signalDispatcher
36
     */
37
    public function __construct(URLServiceInterface $service, SignalDispatcher $signalDispatcher)
38
    {
39
        $this->service = $service;
40
        $this->signalDispatcher = $signalDispatcher;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function createUpdateStruct()
47
    {
48
        return $this->service->createUpdateStruct();
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function findUrls(URLQuery $query)
55
    {
56
        return $this->service->findUrls($query);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function findUsages(URL $url, $offset = 0, $limit = -1)
63
    {
64
        return $this->service->findUsages($url, $offset, $limit);
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function loadById($id)
71
    {
72
        return $this->service->loadById($id);
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function loadByUrl($url)
79
    {
80
        return $this->service->loadByUrl($url);
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function updateUrl(URL $url, URLUpdateStruct $struct)
87
    {
88
        $returnValue = $this->service->updateUrl($url, $struct);
89
90
        $this->signalDispatcher->emit(
91
            new UpdateUrlSignal([
92
                'urlId' => $returnValue->id,
0 ignored issues
show
Documentation introduced by
The property $id is declared protected in eZ\Publish\API\Repository\Values\URL\URL. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
93
            ])
94
        );
95
96
        return $returnValue;
97
    }
98
}
99