Download the PHP package pangora/classnames without Composer
On this page you can find all versions of the php package pangora/classnames. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pangora/classnames
More information about pangora/classnames
Files in pangora/classnames
Package classnames
Short Description Elegant classlist builder with conditionals
License MIT
Homepage https://github.com/pangora/classnames
Informations about the package classnames
Classnames for PHP
This package replicates the functionality of the popular JS package JedWatson/classnames, allowing you to easily build HTML classlists using strings, stringable objects and arrays with conditions, like this:
Installation
You can install the package via composer:
Usage
Classnames accepts multiple arguments through the static from
method and it'll respect the argument order when building the classlist. The from
method won't remove duplicates, but you may use the static dedupeFrom
, which works the same way, while also removing duplicates.
The allowed argument types are:
string
int
(will be converted tostring
)- Any "stringable" object implementing the magic
__toString()
method. - Sequential arrays
- Associative arrays where the key represents the value and the value represent the condition.
Arguments of other types will be ignored, except for multidimensional array which will throw an exception.
You may also deduplicate the classlist using dedupefrom
:
Testing
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Jarand K. Løkeland
- All Contributors
License
The MIT License (MIT). Please see License File for more information.