PHP code example of liyuze / method-chaining-proxy
1. Go to this page and download the library: Download liyuze/method-chaining-proxy 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/ */
liyuze / method-chaining-proxy example snippets
/**
* Call the given Closure with the given value then return the value.
*
* @param mixed $value
* @param callable|null $callback
* @return mixed
*/
function tap($value, $callback = null)
{
if (is_null($callback)) {
return new HigherOrderTapProxy($value);
}
$callback($value);
return $value;
}
namespace Illuminate\Support\Traits;
trait EnumeratesValues
{
...
/**
* Pass the collection to the given callback and return the result.
*
* @param callable $callback
* @return mixed
*/
public function pipe(callable $callback)
{
return $callback($this);
}
...
}
class Cat
{
public string $name;
public int $age;
public function __construct(string $name, int $age)
{
$this->name = $name;
$this->age = $age;
}
public function getName()
{
return $this->name;
}
public function getAge()
{
return $this->age;
}
public function setName(string $name)
{
$this->name = $name;
}
public function setAge(int $age)
{
$this->age = $age;
}
public function setNameForChaining(string $name)
{
$this->name = $name;
return $this;
}
public function setAgeForChaining(int $age)
{
$this->age = $age;
return $this;
}
public function do(\Closure $closure)
{
$closure();
return $this;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.