public static function create($id, $name, $type) { $instance = new FieldMetadata(); assert(is_integer($id)); assert(is_string($name)); assert(Type::isValid($type)); $instance->id = $id; $instance->name = $name; $instance->type = $type; return $instance; }
public function __construct($type, $callback, $id = null) { if (!Type::isValid($type)) { throw new Exception('Bad event type: ' . $type); } if (!is_callable($callback)) { throw new Exception('Is not callable listener'); } $this->callback = $callback; $this->type = $type; $this->id = $id; }
public function testValuesInvalidShouldReturnFalse() { $this->assertFalse(Type::isValid(0)); $this->assertFalse(Type::isValid(4)); }