Passed
Branch master (4407aa)
by ANTHONIUS
03:52
created

AbstractUserManager   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 74
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A findUserByUsername() 0 3 1
A __construct() 0 4 1
A findUserByEmail() 0 3 1
A findUserByConfirmationToken() 0 3 1
A findUserByUsernameOrEmail() 0 10 3
A createUser() 0 5 1
A updateCanonicalFields() 0 3 1
A updatePassword() 0 3 1
1
<?php
0 ignored issues
show
Coding Style introduced by
Class found in ".php" file; use ".inc" extension instead
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "AbstractUserManager.php" doesn't match the expected filename "abstractusermanager.php"
Loading history...
2
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
3
/*
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
4
 * This file is part of the DoyoUserBundle project.
5
 *
6
 * (c) Anthonius Munthi <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Doyo\UserBundle\Manager;
15
16
use Doyo\UserBundle\Model\UserInterface;
17
use Doyo\UserBundle\Util\CanonicalFieldsUpdaterInterface;
18
use Doyo\UserBundle\Util\PasswordUpdaterInterface;
19
20
/**
21
 * Abstract User Manager implementation which can be used as base class for your
22
 * concrete manager.
23
 *
24
 * This class is taken from friendsofsymfony/user-bundle
25
 *
26
 * @author Johannes M. Schmitt <[email protected]>
0 ignored issues
show
Coding Style Documentation introduced by
@author tag is not allowed in class comment
Loading history...
27
 * @author Anthonius Munthi <[email protected]>
0 ignored issues
show
Coding Style Documentation introduced by
@author tag is not allowed in class comment
Loading history...
28
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
29
abstract class AbstractUserManager implements UserManagerInterface
30
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class AbstractUserManager
Loading history...
31
    private $passwordUpdater;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
Coding Style introduced by
Private member variable "passwordUpdater" must contain a leading underscore
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "passwordUpdater" must be prefixed with an underscore
Loading history...
32
    private $canonicalFieldsUpdater;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before member var; 0 found
Loading history...
Coding Style introduced by
Private member variable "canonicalFieldsUpdater" must contain a leading underscore
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "canonicalFieldsUpdater" must be prefixed with an underscore
Loading history...
33
34 13
    public function __construct(PasswordUpdaterInterface $passwordUpdater, CanonicalFieldsUpdaterInterface $canonicalFieldsUpdater)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 131 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
35
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
36 13
        $this->passwordUpdater        = $passwordUpdater;
37 13
        $this->canonicalFieldsUpdater = $canonicalFieldsUpdater;
38
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end __construct()
Loading history...
39
40
    /**
41
     * {@inheritdoc}
42
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
43 3
    public function createUser()
44
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
45 3
        $class = $this->getClass();
46
47 3
        return new $class();
48
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end createUser()
Loading history...
49
50
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $email should have a doc-comment as per coding-style.
Loading history...
51
     * {@inheritdoc}
52
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
53 2
    public function findUserByEmail($email)
54
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
55 2
        return $this->findUserBy(['emailCanonical' => $this->canonicalFieldsUpdater->canonicalizeEmail($email)]);
0 ignored issues
show
Coding Style introduced by
Short array syntax is not allowed
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 113 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
56
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end findUserByEmail()
Loading history...
57
58
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $username should have a doc-comment as per coding-style.
Loading history...
59
     * {@inheritdoc}
60
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
61 6
    public function findUserByUsername($username)
62
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
63 6
        return $this->findUserBy(['usernameCanonical' => $this->canonicalFieldsUpdater->canonicalizeUsername($username)]);
0 ignored issues
show
Coding Style introduced by
Short array syntax is not allowed
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 122 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
64
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end findUserByUsername()
Loading history...
65
66
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $usernameOrEmail should have a doc-comment as per coding-style.
Loading history...
67
     * {@inheritdoc}
68
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
69 1
    public function findUserByUsernameOrEmail($usernameOrEmail)
70
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
71 1
        if (preg_match('/^.+\@\S+\.\S+$/', $usernameOrEmail)) {
72 1
            $user = $this->findUserByEmail($usernameOrEmail);
73 1
            if (null !== $user) {
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
74 1
                return $user;
75
            }
76
        }
77
78 1
        return $this->findUserByUsername($usernameOrEmail);
79
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end findUserByUsernameOrEmail()
Loading history...
80
81
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $token should have a doc-comment as per coding-style.
Loading history...
82
     * {@inheritdoc}
83
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
84 1
    public function findUserByConfirmationToken($token)
85
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
86 1
        return $this->findUserBy(['confirmationToken' => $token]);
0 ignored issues
show
Coding Style introduced by
Short array syntax is not allowed
Loading history...
87
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end findUserByConfirmationToken()
Loading history...
88
89
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $user should have a doc-comment as per coding-style.
Loading history...
90
     * {@inheritdoc}
91
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
92 6
    public function updateCanonicalFields(UserInterface $user)
93
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
94 6
        $this->canonicalFieldsUpdater->updateCanonicalFields($user);
95
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end updateCanonicalFields()
Loading history...
96
97
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $user should have a doc-comment as per coding-style.
Loading history...
98
     * {@inheritdoc}
99
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
100 6
    public function updatePassword(UserInterface $user)
101
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
102 6
        $this->passwordUpdater->hashPassword($user);
103
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end updatePassword()
Loading history...
104
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
105