getBody() public method

public getBody ( ) : string
return string
Example #1
0
 public function testMethodBodyGetterAndSetter()
 {
     $method = new MethodGenerator();
     $method->setBody('Foo');
     $this->assertEquals('Foo', $method->getBody());
 }
 /**
  * Given a factory method, extend the class being constructed and create
  * a new factory for the subclass.
  *
  * @param MethodGenerator $method Method to modify
  * @param string          $ns     Namespace of old factory
  * @param string          $module Module in which to make changes
  *
  * @return void
  * @throws \Exception
  */
 protected function createServiceClassAndUpdateFactory(MethodGenerator $method, $ns, $module)
 {
     $body = $method->getBody();
     $regex = '/new\\s+([\\w\\\\]*)\\s*\\(/m';
     preg_match_all($regex, $body, $matches);
     $classNames = $matches[1];
     $count = count($classNames);
     if ($count != 1) {
         throw new \Exception("Found {$count} class names; expected 1.");
     }
     $className = $classNames[0];
     // Figure out fully qualified name for purposes of createSubclassInModule():
     $fqClassName = substr($className, 0, 1) != '\\' ? "{$ns}\\{$className}" : $className;
     $newClass = $this->createSubclassInModule($fqClassName, $module);
     $body = preg_replace('/new\\s+' . addslashes($className) . '\\s*\\(/m', 'new \\' . $newClass . '(', $body);
     $method->setBody($body);
 }