dev-master
9999999-dev
MIT
The Development Requires
by Mateusz Charytoniuk
1.2.0
1.2.0.0
MIT
The Development Requires
by Mateusz Charytoniuk
This package is a PHP port of https://github.com/JedWatson/classnames., (*1)
The only difference is that Classnames
deduplicate classes by default.
It means that Classnames::make('foo', 'foo', 'bar)
returns 'foo bar'
instead of foo foo bar
by default. It's because redraws in PHP do not
happen that often as they do in JavaScript (original implementation) so
it's not an issue and the output code is cleaner and smaller (which is
more an issue in the backend)., (*2)
If you want to use Classnames
without deduplication you can call
Classnames::flatten
., (*3)
use Newride\Classnames\Classnames; Classnames::make('foo', 'bar'); // => 'foo bar' Classnames::make('foo', [ 'bar' => true ]); // => 'foo bar' Classnames::make([ 'foo-bar' => true ]); // => 'foo-bar' Classnames::make([ 'foo-bar' => false ]); // => '' Classnames::make([ 'foo' => true ], [ 'bar' => true ]); // => 'foo bar' Classnames::make([ 'foo' => true, 'bar' => true ]); // => 'foo bar' Classnames::make(1, 2, 3); // => '1 2 3' Classnames::make('foo', 'foo', 'bar'); // => 'foo bar' Classnames::flatten('foo', 'foo', 'bar'); // => 'foo foo bar'
When type non convertible to string is used as an argument then exception is thrown., (*4)
Classnames::flatten(new stdClass()); // => throws \Newride\Classnames\NotConvertibleTypeException
MIT
MIT