/** * @test */ function it_can_return_a_subset_using_globs_to_match_keys() { $lines = FileLines::fromArray(['FOO=BAR', 'FOX=red', 'FOOD=hot bar']); $this->assertSame(['FOO' => 'BAR', 'FOOD' => 'hot bar'], $lines->whereKeysLike('FOO*')->toDictionary()->all()); $this->assertSame(['FOO' => 'BAR', 'FOX' => 'red'], $lines->whereKeysLike('FO[OX]')->toDictionary()->all()); $this->assertSame(['FOO' => 'BAR', 'FOX' => 'red'], $lines->whereKeysLike(['FOO', 'FOX'])->toDictionary()->all()); }
/** * Get the lines as key => value pairs, where the keys match the given glob-style patterns. * * @param $patterns * * @return Collection */ public function dictionaryWithKeysMatching($patterns) { return $this->lines->whereKeysLike($patterns)->toDictionary(); }