/** * getContents() * * @return string */ public function getContents() { $filter = new \Zend\Filter\Word\DashToCamelCase(); $className = $filter->filter($this->_forControllerName) . 'ControllerTest'; $codeGenFile = new Php\PhpFile(array('requiredFiles' => array('PHPUnit/Framework/TestCase.php'), 'classes' => array(new Php\PhpClass(array('name' => $className, 'extendedClass' => 'PHPUnit_Framework_TestCase', 'methods' => array(new Php\PhpMethod(array('name' => 'setUp', 'body' => ' /* Setup Routine */')), new Php\PhpMethod(array('name' => 'tearDown', 'body' => ' /* Tear Down Routine */')))))))); return $codeGenFile->generate(); }
/** * getContents() * * @return string */ public function getContents() { $filter = new \Zend\Filter\Word\DashToCamelCase(); $className = $filter->filter($this->_forClassName) . 'Test'; $codeGenFile = new FileGenerator(); $codeGenFile->setRequiredFiles(array('PHPUnit/Framework/TestCase.php')); $codeGenFile->setClasses(array(new ClassGenerator($className, null, null, 'PHPUnit_Framework_TestCase', array(), array(), array(new MethodGenerator('setUp', array(), MethodGenerator::FLAG_PUBLIC, ' /* Setup Routine */'), new MethodGenerator('tearDown', array(), MethodGenerator::FLAG_PUBLIC, ' /* Tear Down Routine */'))))); return $codeGenFile->generate(); }
/** * @param $name * @param SlackConfig $slackConfig * @return RandomQuoteInterface * @throws \Exception */ public static function createRandomQuoteByName($name, SlackConfig $slackConfig) { $filter = new \Zend\Filter\Word\DashToCamelCase(); $className = self::CONCRETE_CLASSES_NAMESPACE . $filter->filter($name) . 'RandomQuote'; if (!class_exists($className)) { throw new \Exception('Missing RandomQuote Class: ' . $className); } return new $className(self::createSlackBot($slackConfig)); }
/** \Zend\Filter\DashToCamelCase() => */ public function index19Action() { $filter = new \Zend\Filter\Word\DashToCamelCase(); $input = 'Zend-framework-is-Easy'; $output = $filter->filter($input); echo "<h3>" . $input . "</h3>"; echo "<h3>" . $output . "</h3>"; return false; }
private function getPrefixFactory($prefix) { return function ($functionName) use($prefix) { $filter = new Zend\Filter\Word\DashToCamelCase(); // Workaround Deprecated errors showing from Zend lib if (error_reporting() & E_DEPRECATED) { $old_error_reporting = error_reporting(); error_reporting($old_error_reporting - E_DEPRECATED); } $ucname = $filter->filter(ucfirst($functionName)); if (isset($old_error_reporting)) { error_reporting($old_error_reporting); } $class = $prefix . $ucname; if (class_exists($class)) { return new $class(); } }; }
/** * getContents() * * @return string */ public function getContents() { $filter = new \Zend\Filter\Word\DashToCamelCase(); $className = $filter->filter($this->_projectProviderName) . 'Provider'; $class = new ClassGenerator($className, null, null, '\\Zend\\Tool\\Project\\Provider\\AbstractProvider'); $methods = array(); foreach ($this->_actionNames as $actionName) { $methods[] = new MethodGenerator($actionName, array(), MethodGenerator::FLAG_PUBLIC, ' /** @todo Implementation */'); } if ($methods) { $class->setMethods($methods); } $codeGenFile = new \Zend\Code\Generator\FileGenerator(); $codeGenFile->setClass($class); return $codeGenFile->generate(); }
/** * getContents() * * @return string */ public function getContents() { $filter = new \Zend\Filter\Word\DashToCamelCase(); $className = $filter->filter($this->_projectProviderName) . 'Provider'; $class = new \Zend\CodeGenerator\Php\PhpClass(array( 'name' => $className, 'extendedClass' => '\Zend\Tool\Project\Provider\AbstractProvider' )); $methods = array(); foreach ($this->_actionNames as $actionName) { $methods[] = new \Zend\CodeGenerator\Php\PhpMethod(array( 'name' => $actionName, 'body' => ' /** @todo Implementation */' )); } if ($methods) { $class->setMethods($methods); } $codeGenFile = new \Zend\CodeGenerator\Php\PhpFile(array( 'classes' => array($class) )); return $codeGenFile->generate(); }
public function getEntityById($nameSize, $entityContextName, $entityContextId) { $filter = new \Zend\Filter\Word\DashToCamelCase(); $method = 'id' . $filter->filter($nameSize); return \Codeception\Module\Doctrine2::$em->getRepository($entityContextName)->findOneBy(array($method => $entityContextId)); }