public function __construct(array $types) { foreach ($types as $key => $value) { if (in_array($key, $this->_acceptableKeys)) { $this->{$key} = $value; } else { throw new \Exception('the key ' . $key . ' does not support'); } } }