datatypes / datatypes
Data type classes for PHP
Installs: 28 661
Dependents: 11
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
Requires (Dev)
- phpunit/phpunit: ^9.0
README
Data Types is a collection of data types classes for PHP.
Requirements
- PHP >= 8.0
Install with Composer
$ composer require datatypes/datatypes
Basic usage
<?php use DataTypes\Net\EmailAddress; use DataTypes\Net\Url; require __DIR__ . '/vendor/autoload.php'; // Parse a url. $url = Url::parse('https://www.example.com/foo/bar'); // Prints "https". echo $url->getScheme(); // Prints "https://www.example.com/foo/bar?query". echo $url->withQueryString('query'); $path = $url->getPath(); // Prints "/foo/bar". echo $path; // Prints "/foo/". echo $path->getDirectory(); // Parse an email address. $email = EmailAddress::parse('foo.bar@example.com'); // Prints "example.com". echo $email->getHost(); // Returns false. Url::isValid('foo'); // Returns null. Url::tryParse('foo'); // Throws \DataTypes\Net\Exceptions\UrlInvalidArgumentException. Url::parse('foo');
License
MIT