承接 newridetech/php-classnames 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

newridetech/php-classnames

最新稳定版本:1.2.0

Composer 安装命令:

composer require newridetech/php-classnames

包简介

README 文档

README

This package is a PHP port of https://github.com/JedWatson/classnames.

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).

If you want to use Classnames without deduplication you can call Classnames::flatten.

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.

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

统计信息

  • 总下载量: 32.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 7
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-12