Skip to content
Permalink
Browse files

Typehinting all around for testability, as well as extensibility late…

…r on.
  • Loading branch information...
brandonsavage committed Mar 24, 2013
1 parent 8441b75 commit 7e39d54718fab752c8bcf64aa8b27a018fe8d747
Showing with 7 additions and 8 deletions.
  1. +2 −2 ClientDataStore.php
  2. +3 −3 ClientModel.php
  3. +2 −3 Database.php
@@ -6,8 +6,8 @@ class ClientDataStore {
protected $database;
public function __construct() {
$this->database = new Database();
public function __construct(DataStoreInterface $dsi) {
$this->database = $dsi;
}
public function saveClient($data) {
@@ -9,9 +9,9 @@ class ClientModel
public $validator;
public $data = array();
public function __construct(array $data = array()) {
$this->database = new ClientDataStore();
$this->validator = new ClientValidation();
public function __construct(ClientDataStore $datastore, ValidatorInterface $validator, array $data = array()) {
$this->database = $datastore;
$this->validator = $validator;
$this->data = $data;
}
@@ -7,9 +7,8 @@ class Database implements DataStoreInterface {
protected $database;
public function __construct() {
$this->database = new PDO('mysql:host=localhost;dbname=clients', 'username',
'password');
public function __construct(PDO $pdo) {
$this->database = $pdo;
$this->database->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}

0 comments on commit 7e39d54

Please sign in to comment.
You can’t perform that action at this time.