File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,18 @@ public static function list(array $list): string
1313 {
1414 $ values = [];
1515
16- foreach ($ list as $ value ) {
16+ foreach ($ list as $ key => $ value ) {
1717 if (is_array ($ value )) {
18- $ values [] = static ::list ($ value );
18+ $ token = static ::list ($ value );
1919 } else {
20- $ values [] = $ value ;
20+ $ token = $ value ;
2121 }
22+
23+ if (is_string ($ key )) {
24+ $ token = $ key .' ' .$ token ;
25+ }
26+
27+ $ values [] = $ token ;
2228 }
2329
2430 return sprintf ('(%s) ' , implode (' ' , $ values ));
Original file line number Diff line number Diff line change 6565 expect (Str::list ([]))->toBe ('() ' );
6666});
6767
68+ test ('list returns a properly formatted parenthesized list for an array with string keys ' , function () {
69+ expect (Str::list (['a ' => '"b" ' , 'c ' => '"d" ' ]))->toBe ('(a "b" c "d") ' );
70+ expect (Str::list (['a ' => ['"b" ' , '"c" ' ], 'd ' => '"e" ' ]))->toBe ('(a ("b" "c") d "e") ' );
71+ });
72+
6873test ('enums returns value for a single backed enum ' , function () {
6974 $ result = Str::enums (ImapFlag::Seen);
7075
You can’t perform that action at this time.
0 commit comments