Passed
Push — master ( 9c7246...3b2dd4 )
by Peter
03:42
created

PageLayout::getSharedData()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Website\Http\Controllers\Api;
6
7
use AbterPhp\Framework\Http\Controllers\Admin\ApiAbstract;
8
use AbterPhp\Website\Service\Execute\PageLayout as RepoService;
9
use Psr\Log\LoggerInterface;
10
11
class PageLayout extends ApiAbstract
12
{
13
    const ENTITY_SINGULAR = 'pageLayout';
14
    const ENTITY_PLURAL   = 'pageLayouts';
15
16
    /**
17
     * PageLayout constructor.
18
     *
19
     * @param LoggerInterface $logger
20
     * @param RepoService     $repoService
21
     */
22
    public function __construct(LoggerInterface $logger, RepoService $repoService)
23
    {
24
        parent::__construct($logger, $repoService);
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    public function getSharedData(): array
31
    {
32
        $data = $this->request->getJsonBody();
33
34
        $data['assets'] = !empty($data['assets']) ? $data['assets'] : [];
35
36
        $data = array_merge($data, $data['assets']);
37
38
        unset($data['assets']);
39
40
        return $data;
41
    }
42
}
43