PHP code example of kamilwylegala / immutable-setter
1. Go to this page and download the library: Download kamilwylegala/immutable-setter 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/ */
kamilwylegala / immutable-setter example snippets
use KamilWylegala\ImmutableSetter\Wither;
class Person
{
private $name;
private $age;
private $wither;
public function __construct($name, $age)
{
$this->name = $name;
$this->age = $age;
$this->wither = new Wither($this, ["name", "age"]); //Second param is optional.
}
public function withName($newName)
{
return $this->wither->getInstance("name", $newName);
}
}
$ php composer.phar
return $this->wither->getInstance("arg1", $newArg1)