BEM Class Function (php)
<?php
/**
* BEM Class string generator
*
* @param string $block
* @param string $element
* @param array $mods
* @param bool $string
* @return string
*/
function bem($block = '', $element = null, $mods = [], $string = true) {
$classes = []
$classes[] = $el ? "{$block}__{$el}" : "{$block}";
foreach ($mods as $mod):
if (!$mod) continue;
$classes[] = $el ? "{$block}__{$el}--{$mod}" : "{$block}--{$mod}";
endforeach; // mods
return $string ? implode(" ", $classes) : $classes);
}