File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 1111trait Properties
1212{
1313 /** @var array */
14- protected $ properties = [];
14+ private $ properties = [];
1515
1616 /** @var array */
17- protected $ mutatedProperties = [];
17+ private $ mutatedProperties = [];
1818
1919 /** @var bool Whether accessors and mutators are enabled */
2020 protected $ accessorsAndMutatorsEnabled = false ;
2121
22+ /**
23+ * Get whether this class has any properties
24+ *
25+ * @return bool
26+ */
27+ public function hasProperties ()
28+ {
29+ return ! empty ($ this ->properties );
30+ }
31+
2232 /**
2333 * Get whether a property with the given key exists
2434 *
@@ -95,10 +105,6 @@ protected function setProperty($key, $value)
95105 {
96106 $ this ->properties [$ key ] = $ value ;
97107
98- if ($ this ->accessorsAndMutatorsEnabled ) {
99- $ this ->mutateProperty ($ key );
100- }
101-
102108 return $ this ;
103109 }
104110
@@ -117,7 +123,7 @@ protected function mutateProperty($key)
117123 $ value = array_key_exists ($ key , $ this ->properties )
118124 ? $ this ->properties [$ key ]
119125 : null ;
120- $ this ->mutatedProperties [$ key ] = $ value ; // Prevents repeated checks
126+ $ this ->mutatedProperties [$ key ] = true ; // Prevents repeated checks
121127
122128 $ mutator = Str::camel ('mutate_ ' . $ key ) . 'Property ' ;
123129 if (method_exists ($ this , $ mutator )) {
You can’t perform that action at this time.
0 commit comments