1. Go to this page and download the library: Download nulpunkt/php-stub 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/ */
nulpunkt / php-stub example snippets
use Nulpunkt\PhpStub\Stub;
// A standard Stub
$stub = new Stub([
'answer' => 42,
'callMe' => function($a) { return $a; } # Anything which is a callable
]);
$stub->foo = 'bar';
$stub->myMethod = function() { return 50; };
echo $stub->answer(); # => 42
echo $stub->answer; # => 42
echo $stub->callMe('maybe'); # => 'maybe'
echo $stub->foo; # => 'bar'
echo $stub->myMethod(); # => 50
echo $stub->lol()->hey(); # => $stub
// Different configurations
$stub = new Stub([], ['chainable' => false]);
echo $stub->lol(); # => null
// We can throw exceptions on missing functions
$stub = new Stub([], ['throw' => true]);
echo $stub->lol(); # throws a RuntimeException
$stub = new Stub(
[],
['throw' => true, 'exceptionclass' => 'InvalidArgumentException', 'exceptionmessage' => 'Bad function call']
);
echo $stub->lol(); # throws an InvalidArgumentException with message "Bad function call"
"nulpunkt/php-stub": "dev-master"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.