MyProfileController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 57
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A overviewAction() 0 13 1
1
<?php
2
3
/**
4
 * Copyright 2015 SURFnet B.V.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace OpenConext\ProfileBundle\Controller;
20
21
use OpenConext\ProfileBundle\Security\Guard;
22
use OpenConext\ProfileBundle\Service\UserService;
23
use Psr\Log\LoggerInterface;
24
use Symfony\Component\HttpFoundation\Response;
25
use Symfony\Component\Templating\EngineInterface;
26
27
class MyProfileController
28
{
29
    /**
30
     * @var UserService
31
     */
32
    private $userService;
33
34
    /**
35
     * @var EngineInterface
36
     */
37
    private $templateEngine;
38
39
    /**
40
     * @var Guard
41
     */
42
    private $guard;
43
44
    /**
45
     * @var LoggerInterface
46
     */
47
    private $logger;
48
49
    /**
50
     * @param UserService $userService
51
     * @param EngineInterface $templateEngine
52
     * @param Guard $guard
53
     * @param LoggerInterface $logger
54
     */
55
    public function __construct(
56
        UserService $userService,
57
        EngineInterface $templateEngine,
58
        Guard $guard,
59
        LoggerInterface $logger
60
    ) {
61
        $this->userService    = $userService;
62
        $this->templateEngine = $templateEngine;
63
        $this->guard          = $guard;
64
        $this->logger         = $logger;
65
    }
66
67
    /**
68
     * @return Response
69
     */
70
    public function overviewAction()
71
    {
72
        $this->guard->userIsLoggedIn();
73
74
        $this->logger->notice('Showing My Profile page');
75
76
        $user = $this->userService->getUser();
77
78
        return new Response($this->templateEngine->render(
79
            'OpenConextProfileBundle:MyProfile:overview.html.twig',
80
            ['user' => $user]
81
        ));
82
    }
83
}
84