IndexController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 12
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A Index() 0 20 2
1
<?php
2
3
namespace PhpDraft\Controllers\Commish;
4
5
use \Silex\Application;
6
use Symfony\Component\HttpFoundation\Response;
7
8
class IndexController
9
{
10
  public function Index(Application $app) {
11
    $isAuthenticated = false;
12
    $roles = array();
13
14
    //Leaving this here as we also grab roles below, but LoginUserService->GetCurrentUser() will fetch user via this method too:
15
    $token = $app['security']->getToken();
16
17
    if ($token !== null) {
18
      $usr = $token->getUser();
19
20
      $isAuthenticated = true;
21
      $roles = $usr->getRoles();
22
    }
23
24
    $response = array(
25
      "authenticated" => $isAuthenticated,
26
      "roles" => $roles
27
    );
28
29
    return $app->json($response, Response::HTTP_OK);
30
  }
31
}