1. Go to this page and download the library: Download jmf/type-validation library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jmf / type-validation example snippets
use Jmf\TypeValidation\Type;
// Valid, will not throw an exception.
Type::mustBe('string', 'foo');
// Invalid, will throw an exception.
Type::mustBe('string', 123);
use Jmf\TypeValidation\Type;
$variable = 'foo';
if (Type::is('string', $variable)) {
// Valid
} else {
// Invalid
}
use Jmf\TypeValidation\TypeValidator;
$validator = new TypeValidator();
$variable = 'foo';
if ($validator->isValid('string', $variable)) {
// Valid
} else {
// Invalid
}
namespace App;
use Jmf\TypeValidation\Type;
class PotatoPeeler
{
/**
* @param Potato[] $potatoes
*/
public function peel(array $potatoes): void
{
Type::mustBe('\App\Potato[]', $potatoes);
// ...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.