PHP code example of blainesch / magicoracle

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

    

blainesch / magicoracle example snippets



// Library
e magicOracle\src\Oracle as Oracle;

// Mock Class
class Foo {
	public $publicProperty;
	private $privateProperty;
	protected $protectedProperty;
	public function __construct() {
		$this->publicProperty = 'foo';
		$this->privateProperty = 'bar';
		$this->protectedProperty = 'baz';
	}
	public function publicMethod($words) {
		return $words;
	}
	private function privateMethod() {
		return $this->publicProperty;
	}
}

// new class
$fooBar = new Oracle('Foo');

// Call private method
echo $fooBar->privateMethod(); // 'foo';

// Echo protected variable
echo $fooBar->protectedProperty; // 'baz';

// Set and echo protected variable
echo $fooBar->privateProperty; //  'bar';
$fooBar->privateProperty = 'BlaineSch';
echo $fooBar->privateProperty; // BlaineSch

$fooBar = new Oracle('Foo');

$fooBar = new Oracle('Foo', array('arg1', 'arg2'));

$foo = new Foo('arg1', 'arg2');
$fooBar = new Oracle($foo);