2017 © Pedro Peláez
 

library mime

Mime-type matching

image

axy/mime

Mime-type matching

  • Saturday, January 13, 2018
  • by axy
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

axy\mime

Mime-type matching., (*1)

Latest Stable Version Minimum PHP Version Build Status Coverage Status License, (*2)

  • 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., (*3)

Documentation

Mime-type has the follow format: type/subtype. For example: image/png. It is can be case-insensitive: Image/PNG., (*4)

Pattern can be in the follow formats:, (*5)

  • 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., (*6)

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., (*7)

Matching:, (*8)

$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);

The Versions

13/01 2018

dev-master

9999999-dev https://github.com/axypro/mime

Mime-type matching

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

mime

31/12 2017

1.0.4

1.0.4.0 https://github.com/axypro/mime

Mime-type matching

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

mime

31/12 2017

1.0.3

1.0.3.0 https://github.com/axypro/mime

Mime-type matching

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

mime

31/12 2017

1.0.2

1.0.2.0 https://github.com/axypro/mime

Mime-type matching

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

mime

31/12 2017

1.0.1

1.0.1.0 https://github.com/axypro/mime

Mime-type matching

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

mime

30/12 2017

1.0.0

1.0.0.0 https://github.com/axypro/mime

Mime-type matching

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

mime

30/12 2017

dev-php54

dev-php54 https://github.com/axypro/mime

Mime-type matching

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

mime

30/12 2017

0.1.0

0.1.0.0 https://github.com/axypro/mime

Mime-type matching

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

mime