Dynamically add a method to the class.

@param string   $method
@param callable $callback

@throws \InvalidArgumentException
166282
public function addMethod($method, callable $callback)
    {
        if (!is_string($method)) {
            throw new \InvalidArgumentException('$method must be string');
        }
        $this->plugins[$method] = $callback;
    }
19497
public function addMethod(Method $method)
    {
        if (isset($this->methods[$method->getName()])) {
            throw new RuntimeException(sprintf(
                'The method "%s" exists already.',
                $method->getName()
            ));
        }

        $this->methods[$method->getName()] = $method;

        $method->setClass($this);

        return $this;
    }
304951
public function addCallback(string $name, $callback)
    {
        if (!is_object($callback)) {
            throw new \InvalidArgumentException('Given callback must be an object');
        }

        $this->callbacks[$name] = $callback;
    }
396233
public function setChildrenMethod($method)
    {
        // Check method is valid
        if (!$this->rootNode->hasMethod($method)) {
            throw new InvalidArgumentException(sprintf(
                "Can't find the method '%s' on class '%s' for getting tree children",
                $method,
                get_class($this->rootNode)
            ));
        }
        $this->childrenMethod = $method;
        return $this;
    }
603275
public function setCallback($callback)
    {
        if (!is_callable($callback)) {
            throw new Exception\InvalidArgumentException('Invalid callback provided');
        }

        $this->options['callback'] = $callback;
        return $this;
    }
167963
public function setMethod($method)
    {
        if(!in_array(strtoupper($method), $this->allowedMethods)) {
          throw new \InvalidArgumentException("The HTTP Client doesn't accept $method requests.");
        }

        $this->method = $method;
        return $this;
    }
974150
public function addMethod($method)
    {
        // Capitalise method
        $method = strtoupper($method);

        if (!in_array($method, self::$availableMethods)) {
            throw new InvalidArgumentException(sprintf('Invalid method for route with path "%s". Method must be one of: ' . implode(', ', self::$availableMethods) . '. Got "%s" instead.', $this->getPath(), $method));
        }

        if (!in_array($method, $this->methods)) {
            $this->methods[] = $method;
        }

        // Add HEAD method if GET has been allowed for this Route
        if ($method == 'GET') {
            $this->addMethod('HEAD');
        }

        return $this;
    }
69198
protected function useObjectMethod($method, $value)
    {
        $currentObject = $this->getCurrentObject();

        if ($currentObject === null) {
            throw new FilterException(
                "The target object was not provided to the filter, can't execute method. Please report this."
            );
        }

        if (! method_exists($currentObject, $method)) {
            throw new InvalidCallbackException(
                sprintf(
                    "CallbackFilter: Method '%s' not found in object of type '%s'",
                    $method,
                    get_class($currentObject)
                )
            );
        }

        return $currentObject->$method($value);
    }
960734
public function add($method)
    {
        if (!$method instanceof MethodInterface) {
            throw new \InvalidArgumentException('This Method must be a instance of \ClassGeneration\MethodInterface');
        }
        if ($method->getName() === null) {
            $method->setName('method' . ($this->count() + 1));
        }

        parent::set($method->getName(), $method);
        return true;
    }
242849
public function bind( $key, $callback ){
		if( is_callable( $callback ) )
			$callback	= new ADT_Event_Callback( $callback );
		if( !( $callback instanceof ADT_Event_Callback ) )
			throw new InvalidArgumentException( 'Callback must be function or instance of ADT_Event_Callback' );
		if( !is_array( $list = $this->events->get( $key ) ) )
			$list	= array();
		$list[]	= array( $key, $callback );
		$this->events->set( $key, $list );
	}
1086782
public function addMethod($method)
    {
        if (!is_string($method)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Unsupported HTTP method; must be a string, received %s',
                    (is_object($method) ? get_class($method) : gettype($method))
                )
            );
        }

        // According to RFC, methods are defined in uppercase (See RFC 7231)
        $method = strtoupper($method);

        $validHttpMethods = [
            'CONNECT',
            'DELETE',
            'GET',
            'HEAD',
            'OPTIONS',
            'PATCH',
            'POST',
            'PUT',
            'TRACE',
        ];

        if (!in_array($method, $validHttpMethods)) {
            throw new InvalidArgumentException(sprintf(
                'Unsupported HTTP method; must be one of "%s", received "%s"',
                implode('","', $validHttpMethods),
                $method
            ));
        }

        $this->methods[] = $method;

        return $this;
    }
1188450
public function setMethod($method) {
        $method = (int) $method;
        switch ($this->method) {
            case self::METHOD_AUTO:
            case self::METHOD_GET:
            case self::METHOD_POST:
                $this->method = $method;
                break;
            default:
                throw new InvalidArgumentException();
        }
    }
484322
public function extend($id, callable $callback)
    {
        if (is_callable($callback) || method_exists($callback, '__invoke')) {
            $this->callables[$id] = $callback;
        }
    }
751665
public static function addRule($name, $callback, $message = 'error param')
    {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException('param $callback must can callable');
        }
        self::$errorTip[strtolower($name)] = $message;
        static::$rules[$name] = $callback;
    }
1207992
public function define($ability, $callback)
    {
        if (is_callable($callback)) {
            $this->abilities[$ability] = $callback;
        } elseif (is_string($callback)) {
            $this->stringCallbacks[$ability] = $callback;

            $this->abilities[$ability] = $this->buildAbilityCallback($ability, $callback);
        } else {
            throw new InvalidArgumentException("Callback must be a callable or a 'Class@method' string.");
        }

        return $this;
    }
284410
public function withMethod($method)
    {
        $new = clone $this;

        if (!is_string($method) ||
            !preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)
        ) {
            throw new InvalidArgumentException(sprintf(
                'Unsupported HTTP method "%s" provided',
                $method
            ));
        }
        $new->_environment['REQUEST_METHOD'] = $method;

        return $new;
    }
195492
public function setCallback($callback)
    {
        // taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier/
        $pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u';
        $parts = explode('.', $callback);

        foreach ($parts as $part)
        {
            if (!preg_match($pattern, $part)) {
                throw new InvalidArgumentException('The callback name is not valid.');
            }
        }

        $this->_padding = $callback;
    }