neoncitylights / data-url
Allows working with data URLs as entity objects in PHP
Fund package maintenance!
neoncitylights
Installs: 10 050
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- php: >= 8.2
- neoncitylights/media-type: ^3.1.0
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 45.0.0
- mediawiki/minus-x: 1.1.3
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpunit/phpunit: 11.5.1
This package is auto-updated.
Last update: 2024-12-23 06:03:13 UTC
README
A small PHP library for dealing with data URLs, which contain a media type and an encoded base64 string.
This library fully conforms to RFC 2397.
Install
This requires a minimum PHP version of v8.2.
composer require neoncitylights/data-url
Usage
<?php use Neoncitylights\DataUrl\DataUrlParser; use Neoncitylights\MediaType\MediaTypeParser; $dataUrlParser = new DataUrlParser( new MediaTypeParser() ); $dataUrl = $dataUrlParser->parseOrNull( 'data:text/plain;base64,VGhlIGZpdmUgYm94aW5nIHdpemFyZHMganVtcCBxdWlja2x5Lg==' ); print( $dataUrl->getMediaType()->getEssence() ); // 'text/plain' print( $dataUrl->getData() ); // `VGhlIGZpdmUgYm94aW5nIHdpemFyZHMganVtcCBxdWlja2x5Lg==` print( $dataUrl->getDecodedValue() ); // 'The five boxing wizards jump quickly.'
License
This software is licensed under the MIT license (LICENSE
or
https://opensource.org/license/mit/).
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.