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

Page::getSharedData()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 4
nop 0
dl 0
loc 12
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\Page as RepoService;
9
use Psr\Log\LoggerInterface;
10
11
class Page extends ApiAbstract
12
{
13
    const ENTITY_SINGULAR = 'page';
14
    const ENTITY_PLURAL   = 'pages';
15
16
    /**
17
     * Page 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['meta']   = !empty($data['meta']) ? $data['meta'] : [];
35
        $data['assets'] = !empty($data['assets']) ? $data['assets'] : [];
36
37
        $data = array_merge($data, $data['meta'], $data['assets']);
38
39
        unset($data['meta'], $data['assets']);
40
41
        return $data;
42
    }
43
}
44