AuthenticateController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 3
Metric Value
wmc 4
c 3
b 0
f 3
lcom 1
cbo 4
dl 0
loc 21
rs 10
ccs 11
cts 11
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A before() 0 9 2
A after() 0 3 1
1
<?php
2
3
namespace OpenTribes\Core\Silex\Controller;
4
5
6
7
use OpenTribes\Core\Silex\Repository\WritableRepository;
8
use Symfony\Component\HttpFoundation\RedirectResponse;
9
use Symfony\Component\HttpFoundation\Request;
10
11
class AuthenticateController{
12
    /**
13
     * @var WritableRepository
14
     */
15
    protected $useRepository;
16 4
    public function __construct(WritableRepository $userRepository){
17 4
        $this->useRepository = $userRepository;
18 4
    }
19 4
    public function before(Request $httpRequest){
20
21 4
        $session = $httpRequest->getSession();
22
23 4
        if(!$session->get('username')){
24 1
            return new RedirectResponse('/');
25
        }
26 3
        return '';
27
    }
28 4
    public function after(){
29 4
        $this->useRepository->sync();
30
    }
31
}