AbstractFOSRestController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 27
ccs 4
cts 8
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedServices() 0 7 1
A getViewHandler() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the FOSRestBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
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 FOS\RestBundle\Controller;
13
14
use FOS\RestBundle\View\ViewHandlerInterface;
15
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
16
17
/**
18
 * Controllers using the View functionality of FOSRestBundle.
19
 */
20
abstract class AbstractFOSRestController extends AbstractController
21
{
22
    use ControllerTrait;
23
24
    /**
25
     * @return ViewHandlerInterface
26
     */
27
    protected function getViewHandler()
28
    {
29
        if (!$this->viewhandler instanceof ViewHandlerInterface) {
30
            $this->viewhandler = $this->container->get('fos_rest.view_handler');
31
        }
32
33
        return $this->viewhandler;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 12
    public static function getSubscribedServices()
40
    {
41 12
        $subscribedServices = parent::getSubscribedServices();
42 12
        $subscribedServices['fos_rest.view_handler'] = ViewHandlerInterface::class;
43
44 12
        return $subscribedServices;
45
    }
46
}
47