setOptions(new Pattern\PatternOptions($options)); return $plugin; } /** * Validate the plugin is of the expected type (v3). * * Validates against `$instanceOf`. * * @param mixed $instance * @throws InvalidServiceException */ public function validate($instance) { if (! $instance instanceof $this->instanceOf) { throw new InvalidServiceException(sprintf( '%s can only create instances of %s; %s is invalid', get_class($this), $this->instanceOf, (is_object($instance) ? get_class($instance) : gettype($instance)) )); } } /** * Validate the plugin is of the expected type (v2). * * Proxies to `validate()`. * * @param mixed $plugin * @throws Exception\RuntimeException if invalid */ public function validatePlugin($plugin) { try { $this->validate($plugin); } catch (InvalidServiceException $e) { throw new Exception\RuntimeException($e->getMessage(), $e->getCode(), $e); } } }