Skip to content

Commit 933bb63

Browse files
Allow multiple traits with the same methods
1 parent a1d3377 commit 933bb63

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/BooleanDates.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getAttribute($key)
4646
}
4747

4848
if ($this->hasBooleanDate($key)) {
49-
return $this->attributes[$this->getBooleanDateField($key)] !== null;
49+
return $this->getBooleanDate($key);
5050
}
5151

5252
return parent::getAttribute($key);
@@ -82,7 +82,7 @@ public function getBooleanDates() : array
8282
/**
8383
* @return array
8484
*/
85-
public function getBooleanDateAttributes() : array
85+
protected function getBooleanDateAttributes() : array
8686
{
8787
return array_intersect_key(
8888
$this->attributes,
@@ -91,20 +91,20 @@ public function getBooleanDateAttributes() : array
9191
}
9292

9393
/**
94-
* @param string $key
94+
* @param mixed $key
9595
*
9696
* @return bool
9797
*/
98-
public function hasBooleanDate(string $key) : bool
98+
protected function getBooleanDate($key) : bool
9999
{
100-
return array_key_exists($key, $this->getBooleanDates());
100+
return $this->attributes[$this->getBooleanDateField($key)] !== null;
101101
}
102102

103103
/**
104104
* @param string $key
105105
* @param mixed $value
106106
*/
107-
public function setBooleanDate(string $key, $value) : void
107+
protected function setBooleanDate(string $key, $value) : void
108108
{
109109
// Only update the timestamp if the value is true and if it's not yet set
110110
// or if the value is false and we need to unset the field.
@@ -118,7 +118,17 @@ public function setBooleanDate(string $key, $value) : void
118118
*
119119
* @return bool
120120
*/
121-
public function currentBooleanDateFieldValueIsNotYetSet(string $key) : bool
121+
protected function hasBooleanDate(string $key) : bool
122+
{
123+
return array_key_exists($key, $this->getBooleanDates());
124+
}
125+
126+
/**
127+
* @param mixed $key
128+
*
129+
* @return bool
130+
*/
131+
protected function currentBooleanDateFieldValueIsNotYetSet($key) : bool
122132
{
123133
if (! array_key_exists($this->getBooleanDateField($key), $this->attributes)) {
124134
return true;
@@ -128,11 +138,11 @@ public function currentBooleanDateFieldValueIsNotYetSet(string $key) : bool
128138
}
129139

130140
/**
131-
* @param string $key
141+
* @param mixed $key
132142
*
133143
* @return string
134144
*/
135-
public function getBooleanDateField(string $key) : string
145+
protected function getBooleanDateField($key) : string
136146
{
137147
return $this->booleanDates[$key];
138148
}
@@ -142,7 +152,7 @@ public function getBooleanDateField(string $key) : string
142152
*
143153
* @return string|null
144154
*/
145-
public function getNewBooleanDateValue($value) : ?string
155+
protected function getNewBooleanDateValue($value) : ?string
146156
{
147157
return $value ? $this->fromDateTime(Carbon::now()) : null;
148158
}

0 commit comments

Comments
 (0)