PHP code example of hoa / consistency

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

    

hoa / consistency example snippets


$isKeyword = Hoa\Consistency\Consistency::isKeyword('yield');

$isValidIdentifier = Hoa\Consistency\Consistency::isIdentifier('foo');

Hoa\Consistency\Consistency::flexEntity('Foo\Bar\Exception\Exception');

try {
    …
} catch (Throwable $e) {
    …
}

$autoloader = new Hoa\Consistency\Autoloader();
$autoloader->addNamespace('Foo\Bar', 'Source');
$autoloader->register();

$baz = new Foo\Bar\Baz(); // automatically loaded!

$xcallable = new Hoa\Consistency\Xcallable('strtoupper');
var_dump($xcallable('foo'));

/**
 * Will output:
 *     string(3) "FOO"
 */

$xcallable->distributeArguments(['foo']);

var_dump($xcallable->getHash());

/**
 * Will output:
 *     string(19) "function#strtoupper"
 */

var_dump($xcallable->getReflection());

/**
 * Will output:
 *     object(ReflectionFunction)#42 (1) {
 *       ["name"]=>
 *       string(10) "strtoupper"
 *     }
 */

Hoa\Event\Event::getEvent('hoa://Event/Exception')
    ->attach(new Hoa\File\Write('Exceptions.log'));