User   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 15
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A isAuthenticated() 0 10 4
1
<?php
2
3
namespace Kaliop\IdentityManagementBundle\Traits;
4
5
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
6
7
trait User {
8
9
    protected $securityToken = null;
10
11
    protected function isAuthenticated() {
12
        if( $this->securityToken == null ) {
13
            $securityToken = $this->container->get( 'security.token_storage' )->getToken();
0 ignored issues
show
Bug introduced by
The property container does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
14
            if( $securityToken instanceof TokenInterface ) {
0 ignored issues
show
Bug introduced by
The class Symfony\Component\Securi...on\Token\TokenInterface does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
15
                $this->securityToken = $securityToken;
16
            }
17
        }
18
19
        return $this->securityToken->isAuthenticated() === true && count( $this->securityToken->getRoles() );
20
    }
21
}
22