UserStringConverter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 11
ccs 0
cts 8
cp 0
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A convert() 0 10 5
1
<?php
2
3
namespace App\Converter;
4
5
use App\Entity\User;
6
7
class UserStringConverter {
8
    public function convert(User $user): string {
9
        if(empty($user->getLastname()) && empty($user->getFirstname())) {
10
            return $user->getUsername();
11
        } else if(empty($user->getFirstname())) {
12
            return sprintf('%s (%s)', $user->getFirstname(), $user->getUsername());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $user->getFirstname() targeting App\Entity\User::getFirstname() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
13
        } else if(empty($user->getLastname())) {
14
            return sprintf('%s (%s)', $user->getLastname(), $user->getUsername());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $user->getLastname() targeting App\Entity\User::getLastname() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
15
        }
16
17
        return sprintf('%s, %s (%s)', $user->getLastname(), $user->getFirstname(), $user->getUsername());
18
    }
19
}