Completed
Push — master ( fc3d6f...f7b1d9 )
by Sergi Tur
28:05
created

HasUsername   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A username() 0 12 3
1
<?php
2
3
4
namespace Acacha\AdminLTETemplateLaravel\Console;
5
6
/**
7
 * Class HasUsername.
8
 *
9
 * @package Acacha\AdminLTETemplateLaravel\Console
10
 */
11
trait HasUsername
12
{
13
    /**
14
     * Obtains username.
15
     *
16
     * @return mixed|null|string
17
     */
18
    public function username()
19
    {
20
        if (($username = env('ADMIN_USERNAME', null)) != null) {
21
            return $username;
22
        }
23
24
        if (($username = git_user_name()) != null) {
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $username = git_user_name() of type null|string against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
25
            return $username;
26
        }
27
28
        return "Admin";
29
    }
30
}
31