LoginControllerTrait   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 21
c 2
b 0
f 0
dl 0
loc 44
ccs 0
cts 24
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 26 4
A generateModelName() 0 3 1
A oauth() 0 4 1
1
<?php
2
3
namespace ByTIC\Hello\Modules\AbstractModule\Controllers\Traits;
4
5
use Nip\Controllers\Traits\AbstractControllerTrait;
6
use Users;
0 ignored issues
show
Bug introduced by
The type Users was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
/**
9
 * Trait LoginControllerTrait
10
 * @package ByTIC\Hello\Modules\AbstractModule\Controllers\Traits
11
 */
12
trait LoginControllerTrait
13
{
14
    use AbstractControllerTrait;
15
16
    public function index()
17
    {
18
        $usersManager = $this->getModelManager();
0 ignored issues
show
Bug introduced by
It seems like getModelManager() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        /** @scrutinizer ignore-call */ 
19
        $usersManager = $this->getModelManager();
Loading history...
19
        $this->getView()->set('headerTitle', $usersManager->getLabel('login-title'));
20
21
        $loginForm = $this->_getUser()->getForm('login');
0 ignored issues
show
Bug introduced by
It seems like _getUser() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        $loginForm = $this->/** @scrutinizer ignore-call */ _getUser()->getForm('login');
Loading history...
22
23
        if ($loginForm->submited()) {
24
            if ($loginForm->processRequest()) {
25
                $this->doSuccessRedirect();
0 ignored issues
show
Bug introduced by
It seems like doSuccessRedirect() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
                $this->/** @scrutinizer ignore-call */ 
26
                       doSuccessRedirect();
Loading history...
26
            }
27
        } else {
28
            if ($this->getRequest()->query->has('message')) {
29
                $loginForm->addMessage($this->getRequest()->query->get('message'), 'info');
30
            }
31
        }
32
33
        $this->forms['login'] = $loginForm;
0 ignored issues
show
Bug Best Practice introduced by
The property forms does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
34
        $this->getView()->set('redirect', $this->getRedirectURL());
0 ignored issues
show
Bug introduced by
It seems like getRedirectURL() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        $this->getView()->set('redirect', $this->/** @scrutinizer ignore-call */ getRedirectURL());
Loading history...
35
        $this->_setMeta('login');
0 ignored issues
show
Bug introduced by
It seems like _setMeta() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        $this->/** @scrutinizer ignore-call */ 
36
               _setMeta('login');
Loading history...
36
37
        $this->getView()->Breadcrumbs()->addItem(
38
            $this->getModelManager()->getLabel('login-title'),
39
            $this->_getUser()->getManager()->compileURL('login')
40
        );
41
        $this->getView()->Meta()->prependTitle($this->getModelManager()->getLabel('login-title'));
42
    }
43
44
    public function oauth()
45
    {
46
        $jwt = $this->getRequest()->get('token');
47
        $this->_getUser()->getManager()->authenticateWithToken($jwt);
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53
    protected function generateModelName()
54
    {
55
        return get_class($this->_getUser()->getManager());
56
    }
57
}
58