PHP code example of aedon / php-expectations

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

    

aedon / php-expectations example snippets


$value = new stdClass();

if (!$value instanceof stdClass) {
    throw new InvalidArgumentException('some message');
}

$value = new stdClass();

\Aedon\Expect::isInstanceOf($value, stdClass::class);

\Aedon\Expect::registerCustomException('isTrue', InvalidArgumentException::class);

// This will now throw InvalidArgumentException instead of RuntimeException
\Aedon\Expect::isTrue(false); 

\Aedon\Expect::registerCustomException('isTrue', function() {
    return false; // omit this if you still want to throw the default exception 
});