Skip to content
Snippets Groups Projects
Commit 7e7b09cb authored by xamgore's avatar xamgore
Browse files

A common interface to build objects at the Builder helper

parent edfa5556
Branches
Tags
No related merge requests found
......@@ -10,4 +10,20 @@ class Model_Helper_Builder extends Model
// Variable, allows to create new instance in db
$this->data = [self::$create_new => true];
}
/**
* @param array $map
* @return $this
* @throws InvalidArgumentException
*/
public function fromSet(array $map) {
foreach ($map as $name => $value) {
if ($name === '__construct' || $name === 'fromSet' || $name === 'create')
throw new InvalidArgumentException("`$name` field is incorrect");
if (method_exists($this, $name))
$this->{$name}($value);
}
return $this;
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment