Last active
August 29, 2015 14:21
-
-
Save nicholasruunu/792ff06ceb183b5e2512 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
final class DatabaseName implements Name { | |
private $db; | |
private $table; | |
public function __construct(Database $db, string $table) { | |
$this->db = $db; | |
$this->table = $table; | |
} | |
public function rename($name) { | |
$this->db->sql("UPDATE $this->table SET name = $name ..."); | |
} | |
public function toString() { | |
return $this->db->sql("SELECT name FROM $this->table ..."); | |
} | |
} | |
final class ConstantName implements Name { | |
private $origin; | |
private $name; | |
public function __construct(Name $origin, string $name) { | |
$this->origin = $origin; | |
$this->name = $name; | |
} | |
public function rename($name) { | |
$this->origin->rename($name); | |
} | |
public function toString() { | |
return $this->name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment