Assert
Installation
composer require sonsofphp/assertUsage
<?php
use SonsOfPHP\Component\Assert\Assert;
use SonsOfPHP\Component\Assert\InvalidArgumentException;
$data = 'test';
Assert::string($data);
// @throws InvalidArgumentException
Assert::int($data);
// Disable exceptions
Assert::disable();
// @return bool
Assert::int($data);
// Re-enable exceptions
Assert::enable();Assertions
Magic Assertions
Last updated
Was this helpful?