Completed
Push — master ( 9b1ada...794d27 )
by Beñat
03:51
created

MenuDTODataTransformer::translatableClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the CMS Kernel package.
5
 *
6
 * Copyright (c) 2016-present LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LIN3S\CMSKernel\Application\DataTransformer\Menu;
13
14
use LIN3S\CMSKernel\Application\DataTransformer\Translation\TranslatableDTODataTransformer;
15
use LIN3S\CMSKernel\Domain\Model\Menu\Menu;
16
17
/**
18
 * @author Beñat Espiña <[email protected]>
19
 */
20
class MenuDTODataTransformer extends TranslatableDTODataTransformer
21
{
22
    protected function translatableClass()
23
    {
24
        return Menu::class;
25
    }
26
27
    protected function serialize()
28
    {
29
        return [
30
            'id'   => $this->translatable->id()->id(),
0 ignored issues
show
Documentation Bug introduced by
The method id does not exist on object<LIN3S\CMSKernel\D...anslation\Translatable>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
31
            'code' => $this->translatable->code()->code(),
0 ignored issues
show
Documentation Bug introduced by
The method code does not exist on object<LIN3S\CMSKernel\D...anslation\Translatable>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
32
        ];
33
    }
34
}
35