axy/mime
Composer 安装命令:
composer require axy/mime
包简介
Mime-type matching
关键字:
README 文档
README
Mime-type matching.
- The library does not require any dependencies.
- Install:
composer require axy/mime. - License: MIT.
For PHP 5.4+ support see branch php54 in this repo or version 0.x of the composer package.
Documentation
Mime-type has the follow format: type/subtype.
For example: image/png.
It is can be case-insensitive: Image/PNG.
Pattern can be in the follow formats:
image/pngimage/png,image/jpeg, image/gif- a list of allowed types (comma-separated)image/*- all subtype of a typeimage/*,text/plain- a list contains a mask
Matching
use axy\mime\MimeType; $type = 'image/png'; $pattern = 'image/*'; MimeType::match($type, $pattern); // TRUE
Type and pattern can be strings or MimeType and MimePattern instances.
MimeType class
use axy\mime\MimeType; $type = new MimeType('Image/PNG'); echo $type->getMimeType(); // image/png echo $type->getType(); // image echo $type->getSubtype(); // png echo $type->isType('image'); // TRUE echo $type->isType(MimeType::AUDIO); // FALSE
The class has the constants list for common types:
APPLICATION, AUDIO, EXAMPLE, IMAGE, MESSAGE, MODEL, MULTIPART, TEXT and VIDEO.
Matching:
$type = new MimeType('image/png'); $type->match('image/jpeg'); // FALSE $type->match('image/*); // TRUE $type('image/png'); // __invoke() $type($instanceOfMimePattern); // see MimePattern
MimePattern class
use axy\mime\MimePattern; $pattern = new MimePattern('IMAGE/*'); $pattern->getPattern(); // image/* $pattern->match('image/png'); // TRUE $pattern('image/jpeg'); // __invoke $pattern($instanceOfMimeType);
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-30