File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
src/Illuminate/Log/Context Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,28 @@ public function onlyHidden($keys)
193
193
return array_intersect_key ($ this ->hidden , array_flip ($ keys ));
194
194
}
195
195
196
+ /**
197
+ * Retrieve all values except those with the given keys.
198
+ *
199
+ * @param array<int, string> $keys
200
+ * @return array<string, mixed>
201
+ */
202
+ public function except ($ keys )
203
+ {
204
+ return array_diff_key ($ this ->data , array_flip ($ keys ));
205
+ }
206
+
207
+ /**
208
+ * Retrieve all hidden values except those with the given keys.
209
+ *
210
+ * @param array<int, string> $keys
211
+ * @return array<string, mixed>
212
+ */
213
+ public function exceptHidden ($ keys )
214
+ {
215
+ return array_diff_key ($ this ->hidden , array_flip ($ keys ));
216
+ }
217
+
196
218
/**
197
219
* Add a context value.
198
220
*
Original file line number Diff line number Diff line change @@ -364,6 +364,34 @@ public function test_it_can_retrieve_subset_of_context()
364
364
]));
365
365
}
366
366
367
+ public function test_it_can_exclude_subset_of_context ()
368
+ {
369
+ Context::add ('parent.child.1 ' , 5 );
370
+ Context::add ('parent.child.2 ' , 6 );
371
+ Context::add ('another ' , 7 );
372
+
373
+ $ this ->assertSame ([
374
+ 'another ' => 7 ,
375
+ ], Context::except ([
376
+ 'parent.child.1 ' ,
377
+ 'parent.child.2 ' ,
378
+ ]));
379
+ }
380
+
381
+ public function test_it_can_exclude_subset_of_hidden_context ()
382
+ {
383
+ Context::addHidden ('parent.child.1 ' , 5 );
384
+ Context::addHidden ('parent.child.2 ' , 6 );
385
+ Context::addHidden ('another ' , 7 );
386
+
387
+ $ this ->assertSame ([
388
+ 'another ' => 7 ,
389
+ ], Context::exceptHidden ([
390
+ 'parent.child.1 ' ,
391
+ 'parent.child.2 ' ,
392
+ ]));
393
+ }
394
+
367
395
public function test_it_adds_context_to_logging ()
368
396
{
369
397
$ path = storage_path ('logs/laravel.log ' );
You can’t perform that action at this time.
0 commit comments