Skip to content

Instantly share code, notes, and snippets.

@nicholasruunu
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicholasruunu/45d042e8849bdacbe431 to your computer and use it in GitHub Desktop.
Save nicholasruunu/45d042e8849bdacbe431 to your computer and use it in GitHub Desktop.
// 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