/**
  * Set or get a instance of a webservice
  *
  * @param string $name The name of the webservice
  * @param \Muffin\Webservice\Webservice\WebserviceInterface|null $webservice The instance of the webservice you'd like to set
  *
  * @return $this
  */
 public function webservice($name, WebserviceInterface $webservice = null)
 {
     if ($webservice !== null) {
         $this->_webservices[$name] = $webservice;
         return $this;
     }
     if (!isset($this->_webservices[$name])) {
         list($pluginName) = pluginSplit(App::shortName(get_class($this), 'Webservice/Driver'));
         $webserviceClass = implode('.', array_filter([$pluginName, Inflector::camelize($name)]));
         $webservice = $this->_createWebservice($webserviceClass, ['endpoint' => $name, 'driver' => $this]);
         $this->_webservices[$name] = $webservice;
     }
     return $this->_webservices[$name];
 }
 /**
  * Get field type by field handler class name.
  *
  * @param object $handler Field handler instance
  * @return string
  */
 protected function _getFieldTypeByFieldHandler($handler)
 {
     list(, $type) = pluginSplit(App::shortName(get_class($handler), 'FieldHandlers', 'FieldHandler'));
     return Inflector::underscore($type);
 }
 /**
  * {@inheritDoc}
  */
 public function describe($endpoint)
 {
     $shortName = App::shortName(get_class($this), 'Webservice', 'Webservice');
     list($plugin, $name) = pluginSplit($shortName);
     $schemaShortName = implode('.', array_filter([$plugin, Inflector::classify($endpoint)]));
     $schemaClassName = App::className($schemaShortName, 'Model/Endpoint/Schema', 'Schema');
     if ($schemaClassName) {
         return new $schemaClassName($endpoint);
     }
     throw new MissingEndpointSchemaException(['schema' => $schemaShortName, 'webservice' => $shortName]);
 }