1. Go to this page and download the library: Download carlosgoce/expressive 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/ */
//Executes a closure and returns its value
Execute::it(\Closure $callback);
Execute::when($condition, \Closure $callback);
Execute::unless($condition, \Closure $callback);
//As static class
use CarlosGoce\Expressive\Is;
use CarlosGoce\Expressive\Raise;
class MyController
{
public function myMethod()
{
//Easier to use
Raise::when(Is::null($someValue), new \Exception('Some value is null') );
}
}
//Using the express facade
use CarlosGoce\Expressive\Facade\Express;
class MyController
{
public function myMethod()
{
//Easier to use and needs only one import but is more verbose
Express::raise()->when(Express::Is()->null($someValue), new \Exception('Some value is null') );
}
}
//As non static class injected with IOC
use CarlosGoce\Expressive\Is;
use CarlosGoce\Expressive\Raise;
class MyController
{
protected $raise;
protected $is;
public function __construct(Raise $raise, Is $is)
{
$this->raise = $raise;
$this->is = $is;
}
public function myMethod()
{
//Easier to test
$this->raise->when($this->is->null($someValue), new \Exception('Some value is null') );
}
}
//With the Express facade
use CarlosGoce\Expressive\Facade\Express;
class MyController
{
protected $express;
public function __construct(Express $express)
{
$this->express = $express;
}
public function myMethod()
{
//easier to test and use less imports but is more verbose
$this->express->raise()->when( $this->express->is()->null($someValue), new \Exception('Some value is null') );
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.