PHP code example of zheltikov / php-invariant

1. Go to this page and download the library: Download zheltikov/php-invariant 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/ */

    

zheltikov / php-invariant example snippets




unction Zheltikov\Invariant\invariant;

$obj = new DateTime();
invariant($obj instanceof DateTime, 'Object must have type DateTime');

$p = 123;
invariant($p !== null, 'Value can\'t be null');

$max = 100;
invariant($p !== null && $p <= $max, '$p\'s value %d must be <= %d', $p, $max);

shell
$ composer