ValidateCredentials::handle()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.2
cc 4
eloc 9
nc 5
nop 2
1
<?php namespace Anomaly\UsersModule\User\Validation;
2
3
use Anomaly\UsersModule\User\Contract\UserInterface;
4
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
5
use Anomaly\UsersModule\User\Login\LoginFormBuilder;
6
use Anomaly\UsersModule\User\UserAuthenticator;
7
use Symfony\Component\HttpFoundation\Response;
8
9
/**
10
 * Class ValidateCredentials
11
 *
12
 * @link          http://pyrocms.com/
13
 * @author        PyroCMS, Inc. <[email protected]>
14
 * @author        Ryan Thompson <[email protected]>
15
 */
16
class ValidateCredentials
17
{
18
19
    /**
20
     * Handle the validation.
21
     *
22
     * @param  UserAuthenticator $authenticator
23
     * @param  LoginFormBuilder  $builder
24
     * @return bool
25
     */
26
    public function handle(UserAuthenticator $authenticator, LoginFormBuilder $builder)
27
    {
28
        $values = $builder->getFormValues();
29
30
        if (!$response = $authenticator->authenticate($values->all())) {
31
            return false;
32
        }
33
34
        if ($response instanceof UserInterface) {
35
            $builder->setUser($response);
36
        }
37
38
        if ($response instanceof Response) {
0 ignored issues
show
Bug introduced by
The class Symfony\Component\HttpFoundation\Response 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...
39
            $builder->setFormResponse($response);
40
        }
41
42
        return true;
43
    }
44
}
45