2017 © Pedro Peláez
 

library php-classnames

image

newridetech/php-classnames

  • Monday, July 2, 2018
  • by mcharytoniuk
  • Repository
  • 2 Watchers
  • 0 Stars
  • 74 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 111 % Grown

The README.md

classnames

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)

Generate CSS class names

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'

Invalid class names

When type non convertible to string is used as an argument then exception is thrown., (*4)

Classnames::flatten(new stdClass()); // => throws \Newride\Classnames\NotConvertibleTypeException

The Versions

02/07 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Development Requires

by Mateusz Charytoniuk

02/07 2018

1.2.0

1.2.0.0

  Sources   Download

MIT

The Development Requires

by Mateusz Charytoniuk

27/05 2018

1.1.0

1.1.0.0

  Sources   Download

The Development Requires

by Mateusz Charytoniuk

26/05 2018

1.0.2

1.0.2.0

  Sources   Download

The Development Requires

by Mateusz Charytoniuk

12/04 2018

1.0.1

1.0.1.0

  Sources   Download

The Development Requires

by Mateusz Charytoniuk

12/04 2018

1.0.0

1.0.0.0

  Sources   Download

The Development Requires

by Mateusz Charytoniuk