PHP code example of m6w6 / hikke

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

    

m6w6 / hikke example snippets




use hikke\Event;

class Observer implements \SplObserver {
	private $name;
	function __construct($name) {
		$this->name = $name;
	}
	function update(\SplSubject $e) {
		echo "Observer '{$this->name}' notified by '$e' ({$e->getPriority()})\n";
	}
	function proxiedMethodCall($arg) {
		$this->name .= $arg;
	}
}

$event = new Event("my_event");
$event->attach(new Observer("o1"), 1);
$event->attach(new Observer("o2"), 2);
$event->notify();




$proxy = new Event\Proxy;
$proxy->ev1 = 0;
$proxy->ev2 = 1;
$proxy->attach(new Observer("o1"), null, 1);
$proxy->attach(new Observer("o2"), null, 0);
$proxy->attach(new Observer("o3"), "ev2");
$proxy->ev3->attach(new Observer("o2"));

$proxy->proxiedMethodCall("-proxy");
$proxy->notify();