coen-hyde/Shanty-Mongo — Issue #64: Checking requirements in the constructor
Author: filipp
Created: 2012-01-22 19:58:34+00:00
State: open

In Document.php's __construct():

// Initialize input data
if ($this->isNewDocument() && is_array($data)) {
foreach ($data as $key => $value) {
$this->getProperty($key);
}
}

What is the purpose of $this->getProperty($key)? Shouldn't it be $this->setProperty($key, $value)? That would allow us to validate already in the constructor and do stuff like:

$post = new Post($_POST);
$post->save()