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;
    }