Ejemplo n.º 1
0
 public function testRegisterMethodByProvidingEachArgument()
 {
     $method = new Method('rpcMethod', 'array_map', MethodTypes::ONE_WAY);
     $result = $this->server->registerMethod($method->getName(), $method->getCallback(), $method->getType());
     $this->assertSame($this->server, $result, 'Method chaining violation at "registerMethod"');
     $this->assertEquals(array($method), $this->server->getMethods());
 }
Ejemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function registerMethod($name, $callback = null, $type = MethodTypes::BASIC)
 {
     if (!$name instanceof Method) {
         $name = new Method($name, $callback, $type);
     }
     $methodName = $name->getName();
     foreach ($this->methods as &$methods) {
         if (isset($methods[$methodName])) {
             unset($methods[$methodName]);
         }
     }
     $this->methods[$name->getType()][$name->getName()] = $name;
     return $this;
 }