Skip to content

Commit a9a225f

Browse files
committed
Merge branch '8.x'
# Conflicts: # CHANGELOG-8.x.md
2 parents b2b50d2 + 7942bc7 commit a9a225f

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

Arr.php

+26-3
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,17 @@ public static function pull(&$array, $key, $default = null)
493493
return $value;
494494
}
495495

496+
/**
497+
* Convert the array into a query string.
498+
*
499+
* @param array $array
500+
* @return string
501+
*/
502+
public static function query($array)
503+
{
504+
return http_build_query($array, '', '&', PHP_QUERY_RFC3986);
505+
}
506+
496507
/**
497508
* Get one or a specified number of random values from an array.
498509
*
@@ -642,14 +653,26 @@ public static function sortRecursive($array, $options = SORT_REGULAR, $descendin
642653
}
643654

644655
/**
645-
* Convert the array into a query string.
656+
* Conditionally compile classes from an array into a CSS class list.
646657
*
647658
* @param array $array
648659
* @return string
649660
*/
650-
public static function query($array)
661+
public static function toCssClasses($array)
651662
{
652-
return http_build_query($array, '', '&', PHP_QUERY_RFC3986);
663+
$classList = static::wrap($array);
664+
665+
$classes = [];
666+
667+
foreach ($classList as $class => $constraint) {
668+
if (is_numeric($class)) {
669+
$classes[] = $constraint;
670+
} elseif ($constraint) {
671+
$classes[] = $class;
672+
}
673+
}
674+
675+
return implode(' ', $classes);
653676
}
654677

655678
/**

0 commit comments

Comments
 (0)