PHP code example of cyrill / sucre-assertion

1. Go to this page and download the library: Download cyrill/sucre-assertion 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/ */

    

cyrill / sucre-assertion example snippets



reqire __DIR__.'/composer/autoload.php';

use Sucre\Assertion;

// Assertion::disable(); // if you disable Sucre\Assertion (ie. production)
try {
    Assertion::factory()
        ->mustString($string)
        ->mustNull(null)
        ->assert();
} catch (Exception $e) {
    // If passed values is not fulfilled. "assert" methods throw Sucre\Assertion\CompositeAssertionException
    // $e->getFirstException();
    // $e->getLastException();
    // $e->getExceptions();
    echo $e;
}