Zend\Code\Generator\ClassGenerator::getMethod PHP Method

getMethod() public method

public getMethod ( string $methodName ) : MethodGenerator | false
$methodName string
return MethodGenerator | false
    public function getMethod($methodName)
    {
        return $this->hasMethod($methodName) ? $this->methods[strtolower($methodName)] : false;
    }

Usage Example

    public function testMethodAccessors()
    {
        $classGenerator = new ClassGenerator();
        $classGenerator->addMethods(array(
            'methodOne',
            new MethodGenerator('methodTwo')
        ));

        $methods = $classGenerator->getMethods();
        $this->assertEquals(count($methods), 2);
        $this->isInstanceOf(current($methods), '\Zend\Code\Generator\PhpMethod');

        $method = $classGenerator->getMethod('methodOne');
        $this->isInstanceOf($method, '\Zend\Code\Generator\PhpMethod');
        $this->assertEquals($method->getName(), 'methodOne');

        // add a new property
        $classGenerator->addMethod('methodThree');
        $this->assertEquals(count($classGenerator->getMethods()), 3);
    }
All Usage Examples Of Zend\Code\Generator\ClassGenerator::getMethod