Completed
Push — master ( 383e32...dd0ca4 )
by Julien
02:48
created

Administrators::getFullname()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Http\Models;
4
5
use Illuminate\Auth\Authenticatable;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Auth\Passwords\CanResetPassword;
8
use Illuminate\Foundation\Auth\Access\Authorizable;
9
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
10
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
11
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
12
13
14
/**
15
 */
16
class Administrators extends Model implements AuthenticatableContract,
0 ignored issues
show
Coding Style introduced by
The first item in a multi-line implements list must be on the line following the implements keyword
Loading history...
17
    AuthorizableContract,
18
    CanResetPasswordContract{
19
20
21
    use Authenticatable, Authorizable, CanResetPassword;
22
23
    /**
24
     * The database table used by the model.
25
     *
26
     * @var string
27
     */
28
    protected $table = 'administrators';
29
30
    /**
31
     * The attributes that are mass assignable.
32
     *
33
     * @var array
34
     */
35
    protected $fillable = ['name', 'email', 'password'];
36
37
    /**
38
     * The attributes excluded from the model's JSON form.
39
     *
40
     * @var array
41
     */
42
    protected $hidden = ['password', 'remember_token'];
43
44
45
46
    public function getFullname(){
47
        return ucfirst($this->firstname)." ". ucfirst($this->lastname);
0 ignored issues
show
Documentation introduced by
The property firstname does not exist on object<App\Http\Models\Administrators>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property lastname does not exist on object<App\Http\Models\Administrators>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
48
    }
49
50
51
}
52
53
54
55