File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -903,4 +903,23 @@ protected function resolveInternalKey($key) {
903903
904904 return null ;
905905 }
906+
907+ /**
908+ * Remove data from the Brief.
909+ *
910+ * This will resolve aliases and delete the data they point to,
911+ * but *not* the aliases themselves.
912+ *
913+ * @param $key
914+ *
915+ * @return void
916+ */
917+ public function delete ($ key ) {
918+ $ internalKey = $ this ->resolveInternalKey ($ key );
919+ if ($ internalKey === null ) {
920+ // Doesn't exist, so nothing to do.
921+ return ;
922+ }
923+ unset($ this ->store [$ internalKey ]);
924+ }
906925}
Original file line number Diff line number Diff line change @@ -480,6 +480,18 @@ public function testCanUserCustomEmptyFunction(): void
480480 ], ['isEmpty ' => $ test ]);
481481 $ this ->assertFalse ($ Brieful ->isEmpty ());
482482 }
483+
484+ public function testCanDeleteDataFromBrief (): void {
485+ $ Brief = Brief::make (['key ' => 'value ' ]);
486+ $ this ->assertEquals ('value ' , $ Brief ->key );
487+ $ Brief ->delete ('key ' );
488+ $ this ->assertNull ($ Brief ->value );
489+ $ NumericBrief = Brief::make (['value ' , 'not-value ' ]);
490+ $ this ->assertEquals ('value ' , $ NumericBrief ->_0 );
491+ $ NumericBrief ->delete (0 );
492+ $ this ->assertNull ($ NumericBrief ->_0 );
493+
494+ }
483495}
484496
485497/**
You can’t perform that action at this time.
0 commit comments