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

CanonicalFieldsUpdater   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 49
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A updateCanonicalFields() 0 4 1
A __construct() 0 4 1
A canonicalizeUsername() 0 3 1
A canonicalizeEmail() 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 "CanonicalFieldsUpdater.php" doesn't match the expected filename "canonicalfieldsupdater.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\Util;
15
16
use Doyo\UserBundle\Model\UserInterface;
17
18
class CanonicalFieldsUpdater implements CanonicalFieldsUpdaterInterface
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for class CanonicalFieldsUpdater
Loading history...
19
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class CanonicalFieldsUpdater
Loading history...
20
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
     * @var CanonicalizerInterface
22
     */
23
    private $usernameCanonicalizer;
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 "usernameCanonicalizer" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "usernameCanonicalizer" must be prefixed with an underscore
Loading history...
24
25
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
26
     * @var CanonicalizerInterface
27
     */
28
    private $emailCanonicalizer;
0 ignored issues
show
Coding Style introduced by
Private member variable "emailCanonicalizer" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "emailCanonicalizer" must be prefixed with an underscore
Loading history...
29
30
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $usernameCanonicalizer should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $emailCanonicalizer should have a doc-comment as per coding-style.
Loading history...
31
     * CanonicalFieldsUpdater constructor.
32
     */
33 2
    public function __construct(CanonicalizerInterface $usernameCanonicalizer, CanonicalizerInterface $emailCanonicalizer)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
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...
34
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
35 2
        $this->usernameCanonicalizer = $usernameCanonicalizer;
36 2
        $this->emailCanonicalizer    = $emailCanonicalizer;
37
    }
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...
38
39 5
    public function updateCanonicalFields(UserInterface $user)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function updateCanonicalFields()
Loading history...
40
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
41 5
        $user->setUsernameCanonical($this->usernameCanonicalizer->canonicalize($user->getUsername()));
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 102 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...
42 5
        $user->setEmailCanonical($this->emailCanonicalizer->canonicalize($user->getEmail()));
43
    }
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...
44
45
    /**
46
     * Canonicalizes an email.
47
     *
48
     * @param string|null $email
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
49
     *
50
     * @return string|null
51
     */
52
    public function canonicalizeEmail($email)
53
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
54
        return $this->emailCanonicalizer->canonicalize($email);
55
    }
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 canonicalizeEmail()
Loading history...
56
57
    /**
58
     * Canonicalizes a username.
59
     *
60
     * @param string|null $username
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
61
     *
62
     * @return string|null
63
     */
64 4
    public function canonicalizeUsername($username)
65
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
66 4
        return $this->usernameCanonicalizer->canonicalize($username);
67
    }
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 canonicalizeUsername()
Loading history...
68
}
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...
69