composer require ecailles/dom-class-name
use Ecailles\DomClassName\Bem\Bem;
// 'block--block-modifier'
$classname = (new Bem())
->block('block')->modifier('block-modifier')
->value();
use Ecailles\DomClassName\Bem\Bem;
// 'block--block-modifier__element--element-modifier'
$classname = (new Bem())
->block('block')->modifier('block-modifier')
->element('element')->modifier('element-modifier')
->value();
use Ecailles\DomClassName\Bem\Bem;
// 'block--block-modifier__element--element-modifier class1 class2'
$classname = (new Bem())
->block('block')->modifier('block-modifier')
->element('element')->modifier('element-modifier')
->class(['class1', 'class2'])
->value();
use Ecailles\DomClassName\Bem\Bem;
// ['block--block-modifier__element--element-modifier', 'class1', 'class2']
$classnames = (new Bem())
->block('block')->modifier('block-modifier')
->element('element')->modifier('element-modifier')
->class(['class1', 'class2'])
->get();
use Ecailles\DomClassName\Bem\Bem;
// 'block--block-modifier__element--element-modifier class1 class2'
$classname = (new Bem())
->block('block')->modifier('block-modifier')
->element('element')->modifier('element-modifier')
->class(['class1', 'class2'])
->value();
use Ecailles\DomClassName\Bem\Bem;
$bem = (new Bem())->block('block')->class('class');
// 'block class'
echo htmlspecialchars($bem, ENT_QUOTES, 'UTF-8');
use Ecailles\DomClassName\Bem\Bem;
// 'block--block-modifier__element--element-modifier'
$classname = (new Bem())
->blockModifier('block-modifier')
->elementModifier('element-modifier')
->block('block')->element('element')
->value();
use Ecailles\DomClassName\Bem\Bem;
$block = (new Bem())->block('block');
// 'block__element1'
$element1 = $block->clone()->element('element1')->value();
// 'block__element2'
$element2 = $block->clone()->element('element2')->value();
use Ecailles\DomClassName\Bem\Bem;
// 'prefix-block'
$classname = (new Bem())->prefix('prefix')->block('block')->value();
or
use Ecailles\DomClassName\Bem\Bem;
// 'prefix-block'
$classname = (new Bem('prefix'))->block('block')->value();
use Ecailles\DomClassName\Bem\Bem;
// 'prefix__block'
$classname = (new Bem())->prefix('prefix')->prefixSeparator('__')
->block('block')->value();
or
use Ecailles\DomClassName\Bem\Bem;
// 'prefix__block'
$classname = (new Bem('prefix', '__'))->block('block')->value();
use Ecailles\DomClassName\Bem\Bem;
// 'block-element'
$classname = (new Bem())->elementSeparator('-')
->block('block')->element('element')->value();
or
use Ecailles\DomClassName\Bem\Bem;
// 'block-element'
$classname = (new Bem(null, null, '-'))
->block('block')->element('element')->value();
use Ecailles\DomClassName\Bem\Bem;
// 'block-modifier'
$classname = (new Bem())->modifierSeparator('-')
->block('block')->element('modifier')->value();
or
use Ecailles\DomClassName\Bem\Bem;
// 'block-modifier'
$classname = (new Bem(null, null, null, '-'))
->block('block')->modifier('modifier')->value();