定制 axy/mime 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

axy/mime

Composer 安装命令:

composer require axy/mime

包简介

Mime-type matching

关键字:

README 文档

README

Mime-type matching.

Latest Stable Version Minimum PHP Version Build Status Coverage Status License

  • 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/png
  • image/png,image/jpeg, image/gif - a list of allowed types (comma-separated)
  • image/* - all subtype of a type
  • image/*,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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固