Completed
Push — master ( 553bc5...721b68 )
by
unknown
49:35 queued 26:20
created

URLWildcard::visit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the URLWildcard ValueObjectVisitor class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\REST\Server\Output\ValueObjectVisitor;
10
11
use eZ\Publish\Core\REST\Common\Output\ValueObjectVisitor;
12
use eZ\Publish\Core\REST\Common\Output\Generator;
13
use eZ\Publish\Core\REST\Common\Output\Visitor;
14
use eZ\Publish\API\Repository\Values\Content\URLWildcard as URLWildcardValue;
15
16
/**
17
 * URLWildcard value object visitor.
18
 */
19 View Code Duplication
class URLWildcard extends ValueObjectVisitor
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    /**
22
     * Visit struct returned by controllers.
23
     *
24
     * @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
25
     * @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
26
     * @param \eZ\Publish\API\Repository\Values\Content\URLWildcard $data
27
     */
28
    public function visit(Visitor $visitor, Generator $generator, $data)
29
    {
30
        $visitor->setHeader('Content-Type', $generator->getMediaType('UrlWildcard'));
31
        $generator->startObjectElement('UrlWildcard');
32
        $this->visitURLWildcardAttributes($visitor, $generator, $data);
33
        $generator->endObjectElement('UrlWildcard');
34
    }
35
36
    protected function visitURLWildcardAttributes(Visitor $visitor, Generator $generator, URLWildcardValue $data)
0 ignored issues
show
Unused Code introduced by
The parameter $visitor is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
    {
38
        $generator->startAttribute(
39
            'href',
40
            $this->router->generate('ezpublish_rest_loadURLWildcard', array('urlWildcardId' => $data->id))
41
        );
42
        $generator->endAttribute('href');
43
44
        $generator->startAttribute('id', $data->id);
45
        $generator->endAttribute('id');
46
47
        $generator->startValueElement('sourceUrl', $data->sourceUrl);
48
        $generator->endValueElement('sourceUrl');
49
50
        $generator->startValueElement('destinationUrl', $data->destinationUrl);
51
        $generator->endValueElement('destinationUrl');
52
53
        $generator->startValueElement(
54
            'forward',
55
            $this->serializeBool($generator, $data->forward)
56
        );
57
        $generator->endValueElement('forward');
58
    }
59
}
60