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

ImageVariation::visit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the ContentImageVariation 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\SPI\Variation\Values\ImageVariation as ImageVariationValue;
15
16
class ImageVariation extends ValueObjectVisitor
17
{
18
    /**
19
     * @param \eZ\Publish\SPI\Variation\Values\ImageVariation $data
20
     */
21
    public function visit(Visitor $visitor, Generator $generator, $data)
22
    {
23
        $generator->startObjectElement('ContentImageVariation');
24
        $this->visitImageVariationAttributes($visitor, $generator, $data);
25
        $generator->endObjectElement('ContentImageVariation');
26
    }
27
28
    protected function visitImageVariationAttributes(Visitor $visitor, Generator $generator, ImageVariationValue $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...
29
    {
30
        $generator->startAttribute(
31
            'href',
32
            $this->router->generate(
33
                'ezpublish_rest_binaryContent_getImageVariation',
34
                array(
35
                    'imageId' => $data->imageId,
36
                    'variationIdentifier' => $data->name,
37
                )
38
            )
39
        );
40
        $generator->endAttribute('href');
41
42
        $generator->startValueElement('uri', $data->uri);
43
        $generator->endValueElement('uri');
44
45
        if ($data->mimeType) {
46
            $generator->startValueElement('contentType', $data->mimeType);
47
            $generator->endValueElement('contentType');
48
        }
49
50
        if ($data->width) {
51
            $generator->startValueElement('width', $data->width);
52
            $generator->endValueElement('width');
53
        }
54
55
        if ($data->height) {
56
            $generator->startValueElement('height', $data->height);
57
            $generator->endValueElement('height');
58
        }
59
60
        if ($data->fileSize) {
61
            $generator->startValueElement('fileSize', $data->fileSize);
62
            $generator->endValueElement('fileSize');
63
        }
64
    }
65
}
66