innmind / media-type
Model of media types
Installs: 77 238
Dependents: 4
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
pkg:composer/innmind/media-type
Requires
- php: ~8.4
- innmind/immutable: ~6.0
Requires (Dev)
- innmind/black-box: ~6.5
- innmind/coding-standard: ~2.0
- innmind/static-analysis: ~1.3
Suggests
- innmind/black-box: For property based testing
Provides
Conflicts
- innmind/black-box: <6.0|~7.0
README
Model to validate media types (follows RFC6838).
Installation
composer install innmind/media-type
Usage
use Innmind\MediaType\MediaType; $type = MediaType::of('application/json+some-extension; charset=utf-8'); $type->topLevel(); // application $type->subType(); // json $type->suffix(); // some-extension $type->parameters()->first()->name(); // charset $type->parameters()->first()->value(); // utf-8 $type->toString(); // application/json+some-extension; charset=utf-8
If the values are incorrect it will throw an exception. Or you can use MediaType::maybe() that will return an instance of Innmind\Immutable\Maybe.