@@ -13,7 +13,7 @@ abstract class Entity implements JsonSerializable, Arrayable
13
13
/**
14
14
* @return int
15
15
*/
16
- abstract public function getId();
16
+ abstract public function getId(): int ;
17
17
18
18
public function __construct()
19
19
{
@@ -45,7 +45,7 @@ abstract class Entity implements JsonSerializable, Arrayable
45
45
* Make all variables of the object as null
46
46
* @return $this
47
47
*/
48
- public function clearVariables()
48
+ public function clearVariables(): self
49
49
{
50
50
$attributes = get_object_vars($this);
51
51
foreach ($attributes as $attributeName => $attributeValue) {
@@ -57,7 +57,7 @@ abstract class Entity implements JsonSerializable, Arrayable
57
57
/**
58
58
* @return int
59
59
*/
60
- public function getPrimaryKey()
60
+ public function getPrimaryKey(): int
61
61
{
62
62
return $this->getId();
63
63
}
@@ -90,15 +90,13 @@ abstract class Entity implements JsonSerializable, Arrayable
90
90
* get an Array of Changed Attributes
91
91
* @return array
92
92
*/
93
- public function changedAttributesName()
93
+ public function changedAttributesName(): array
94
94
{
95
95
$changedAttributes = [];
96
96
$attributes = $this->toArray();
97
97
foreach ($attributes as $key => $value) {
98
- if (isset($this->originals[$key])) {
99
- if ($value != $this->originals[$key] && !((is_array($this->originals[$key]) || is_object($this->originals[$key])))) {
100
- $changedAttributes[] = $key;
101
- }
98
+ if (isset($this->originals[$key]) && $value !== $this->originals[$key] && ! ((is_array($this->originals[$key]) || is_object($this->originals[$key])))) {
99
+ $changedAttributes[] = $key;
102
100
}
103
101
}
104
102
return $changedAttributes;
@@ -108,7 +106,7 @@ abstract class Entity implements JsonSerializable, Arrayable
108
106
* get an Array of Changed Attributes with new values
109
107
* @return array
110
108
*/
111
- public function getDirty()
109
+ public function getDirty(): array
112
110
{
113
111
$dirty = [];
114
112
$attributes = $this->toArray();
@@ -124,7 +122,7 @@ abstract class Entity implements JsonSerializable, Arrayable
124
122
* get an Array of Changed Attributes with original values
125
123
* @return array
126
124
*/
127
- public function getChanges()
125
+ public function getChanges(): array
128
126
{
129
127
$changes = [];
130
128
@@ -139,11 +137,9 @@ abstract class Entity implements JsonSerializable, Arrayable
139
137
* is any attribute changed?
140
138
* @return bool
141
139
*/
142
- public function isDirty()
140
+ public function isDirty(): bool
143
141
{
144
- if (count($this->changedAttributesName()) > 0) return true;
145
-
146
- return false;
142
+ return count($this->changedAttributesName()) > 0;
147
143
}
148
144
149
145
public function jsonSerialize()
0 commit comments