Adds a method to the class.

@param Method $method The method to add to the class.

@return static The current instance.
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;
    }
821918
private function init($method)
    {
        if (is_string($method) && method_exists($this, $method))
        {
            return $this->$method();
        }

        return $method();
    }
1203353
public function setMethod( $method )
	{
		if ( $method == $this->getMethod() ) { return; }

		$this->_values['method'] = (string) $method;
		$this->setModified();
	}
550188
public static function create(string $method): self
    {
        $self = new self();
        $self->method = $method;

        return $self;
    }
538523
public function setMethod($method)
	{
		if($method == 'any')
			$method = array('get', 'post', 'put', 'delete', 'patch', 'options');
		else if(!is_array($method))
			$method = explode('|', $method);

		$method = array_map(function($value){return trim(strtolower($value));}, $method);
	
		$this->setProperty('method', $method);

		return $this;
	}
1254731
public function addMethod(Method $method, $override = false) {
        $methods = $this->getMethods();
        $key = $method->getName();
        if(array_key_exists($key, $methods) && !$override) {
            throw new \Exception('A Method with the name of: ' . $method->getName() . ' already exists');
        }
        $methods[$key] = $method;
        ksort($methods);
        $this->setMethods($methods);
    }
733096
public function setMethod($method) {
        if (isset(static::$_methodOptionMap[$method])) {
            return $this->setOption(static::$_methodOptionMap[$method],true);
        } else {
            return $this->setOption(CURLOPT_CUSTOMREQUEST,$method);
        }
    }
435100
public function setMethod($method) {
        $methods = array(
            COMPLETION_AGGREGATION_ALL,
            COMPLETION_AGGREGATION_ANY,
        );

        if (in_array($method, $methods)) {
            $this->method = $method;
        } else {
            $this->method = COMPLETION_AGGREGATION_ALL;
        }
    }
576203
public function addCall($method, $params = array())
	{
		$call = array('name' => $method, 'params' => $params);

		$calls = $this->listCalls();
		$calls[] = $call;
		$this->setOption('calls', $calls);

		return $call;
	}
926392
public function methodsEnd($method) {
        if (is_string($method)) {
            $method = array($method);
        }
        $this->rule = "end";
        $this->method = $method;
        return $this;
    }
365133
public function setMethod(string $method) : self
    {
        if ($method == 'GET') {
            $this->setCsrf(false);
        }

        return $this->addAttribute('method', $method);
    }
1139046
public function AddMethod(\Peg\Lib\Definitions\Element\FunctionElement $method)
    {
        $method->parent_class =& $this;
        $this->methods[$method->name] = $method;
        
        return $this;
    }
1132501
public function withMethod($method)
    {
        if ($this->getMethod() === $method) {
            return $this;
        }

        $newInstance = clone $this;
        $newInstance->setMethod($method);
        return $newInstance;
    }
1109264
public function addMethod(MethodGenerator $method)
    {
        $name = $method->getName();
        if (isset($this->methods[$name]) === true) {
            throw new InvalidArgumentException('Method name "' . $name . '" already added.');
        }

        $this->methods[$name] = $method;
    }
945961
public function setMethod($method)
	{
		if ($method === null || !is_array($method) || empty($method)) {
			throw new InvalidArgumentException('No method provided');
		}

		foreach ($method as $m) {
			if (!in_array($m, array('GET','POST','PUT','PATCH','DELETE'))) {
				throw new InvalidArgumentException('Method not allowed. allowed methods: GET, POST, PUT, PATCH, DELETE');
			}
		}

		$this->method = $method;

		return $this;
	}
558759
public function setMethod($method) {
        $this->method = (true === in_array($method, [self::HTTP_METHOD_GET, self::HTTP_METHOD_POST]) ? $method : self::HTTP_METHOD_POST);
        return $this;
    }
280902
public function methodsContains($method) {
        if (is_string($method)) {
            $method = array($method);
        }
        $this->rule = "contains";
        $this->method = $method;
        return $this;
    }