1. Go to this page and download the library: Download jlaswell/assert-php 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/ */
jlaswell / assert-php example snippets
// assert that the size of the $records array is greater than zero
Assert::that('array' === gettype($records));
Assert::that(sizeof($records) > 0);
public function fill(array $values): array
{
Assert::that(sizeof($values) > 0);
Assert::that(sizeof($values) === sizeof(array_filter($values, fn ($value) => is_int($value))));
// logic can now perform on an array with values of integers
}
public function save(Contact[] $contacts): int
{
foreach ($contacts as $contact) {
Assert::that($contact->isValid());
Assert::that(null === $contact->id);
}
// logic can now perform on an array of valid Contacts without a record id
}
use Jlaswell/Assert/Assert;
Assert::that('this' !== 'that');
Assert::isTrue(true);
Assert::isFalse(false);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.