Last active
August 29, 2015 14:21
-
-
Save nicholasruunu/45d042e8849bdacbe431 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Immutable class | |
class Person { | |
private $name; | |
public function __construct(string $name) { | |
$this->name = new Name($name); | |
} | |
public function rename(string $name) { | |
$this->name->rename($name); | |
} | |
public function name() { | |
return $this->name->toString(); | |
} | |
} | |
// Immutable and constant class | |
class Money { | |
private $value; | |
public function __construct(int $value) { | |
$this->value = $value; | |
} | |
public function toValue() { | |
return $this->value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment