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

PageLayout   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSharedData() 0 11 2
A __construct() 0 3 1
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