Completed
Push — master ( 11ad20...a09f6d )
by Sergi Tur
05:23
created

HasUsername::username()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 3
eloc 4
nc 3
nop 0
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
        if (($username = env('ADMIN_USERNAME', null)) != null) return $username;
20
21
        if (($username = git_user_name()) != null) return $username;
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...
22
23
        return "Admin";
24
    }
25
}