User   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 12
c 2
b 1
f 0
lcom 1
cbo 1
dl 0
loc 100
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getFirstname() 0 3 1
A setFirstname() 0 5 1
A getSurname() 0 3 1
A setSurname() 0 5 1
A getRealName() 0 6 3
A getUsernameAndRealName() 0 3 1
A getReversedRealName() 0 7 2
A __toString() 0 3 2
1
<?php
2
3
/*
4
 * This file is part of the Stinger Soft Platform package.
5
 *
6
 * (c) Oliver Kotte <[email protected]>
7
 * (c) Florian Meyer <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
namespace StingerSoft\PlatformBundle\Entity;
13
14
use FOS\UserBundle\Model\User as BaseUser;
15
use StingerSoft\PlatformBundle\Model\Identifiable;
16
17
/**
18
 *
19
 * $LastChangedBy: $
20
 * $LastChangedDate: $
21
 *
22
 * Class User
23
 *
24
 * @package StingerSoft\PlatformBundle\Entity
25
 */
26
class User extends BaseUser implements Identifiable {
27
28
	/**
29
	 *
30
	 * @var integer
31
	 */
32
	protected $id;
33
34
	/**
35
	 *
36
	 * @var string
37
	 */
38
	protected $firstname;
39
40
	/**
41
	 *
42
	 * @var string
43
	 */
44
	protected $surname;
45
46
	/**
47
	 *
48
	 * @return string
49
	 */
50
	public function getFirstname() {
51
		return $this->firstname;
52
	}
53
54
	/**
55
	 *
56
	 * @param string $firstname        	
57
	 *
58
	 * @return $this
59
	 */
60
	public function setFirstname($firstname) {
61
		$this->firstname = $firstname;
62
		
63
		return $this;
64
	}
65
66
	/**
67
	 *
68
	 * @return string
69
	 */
70
	public function getSurname() {
71
		return $this->surname;
72
	}
73
74
	/**
75
	 *
76
	 * @param string $surname        	
77
	 *
78
	 * @return $this
79
	 */
80
	public function setSurname($surname) {
81
		$this->surname = $surname;
82
		
83
		return $this;
84
	}
85
86
	/**
87
	 * Get realname "Firstname Surname"
88
	 *
89
	 * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
90
	 */
91
	public function getRealName() {
92
		if($this->firstname || $this->surname) {
93
			return trim($this->getFirstname() . ' ' . $this->getSurname());
94
		}
95
		return null;
96
	}
97
98
	/**
99
	 *
100
	 * @return string - "Username" ("Firstname Surname")
101
	 */
102
	public function getUsernameAndRealName() {
103
		return $this->getUsername() . ' (' . $this->getRealName() . ')';
104
	}
105
106
	/**
107
	 *
108
	 * @return string "Surname, Firstname"|"Surname"
109
	 */
110
	public function getReversedRealName() {
111
		if($this->getFirstname()) {
112
			return $this->getSurname() . ', ' . $this->getFirstname();
113
		} else {
114
			return $this->getSurname();
115
		}
116
	}
117
118
	/**
119
	 *
120
	 * @return string "Firstname Surname"|"Username"
121
	 */
122
	public function __toString() {
123
		return $this->getRealName() != null ? $this->getRealName() : $this->getUsername();
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $this->getRealName() of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
124
	}
125
}