本文整理匯總了PHP中PhpSpec\Locator\ResourceInterface::getSpecName方法的典型用法代碼示例。如果您正苦於以下問題:PHP ResourceInterface::getSpecName方法的具體用法?PHP ResourceInterface::getSpecName怎麽用?PHP ResourceInterface::getSpecName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PhpSpec\Locator\ResourceInterface
的用法示例。
在下文中一共展示了ResourceInterface::getSpecName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderTemplate
/**
* @param ResourceInterface $resource
* @param string $filepath
*
* @return string
*/
protected function renderTemplate(ResourceInterface $resource, $filepath)
{
$controller = <<<CONTROLLER
function let(\\Fuel\\Core\\Request \$request, \\Fuel\\Core\\Response \$response){
\$this->beConstructedWith(\$request, \$response);
}
CONTROLLER;
$values = array('%filepath%' => $filepath, '%name%' => $resource->getSpecName(), '%namespace%' => $resource->getSpecNamespace(), '%subject%' => $resource->getSrcClassname(), "%constructor%" => preg_match("!^Controller_!i", $resource->getSpecName()) ? $controller : "");
if (!($content = $this->getTemplateRenderer()->render('specification', $values))) {
$content = $this->getTemplateRenderer()->renderString($this->getTemplate(), $values);
}
return $content;
}
示例2: renderTemplate
/**
* @param ResourceInterface $resource
* @param string $filepath
*
* @return string
*/
protected function renderTemplate(ResourceInterface $resource, $filepath)
{
$values = array('%filepath%' => $filepath, '%name%' => $resource->getSpecName(), '%namespace%' => $resource->getSpecNamespace(), '%subject%' => $resource->getSrcClassname());
if (!($content = $this->getTemplateRenderer()->render('specification', $values))) {
$content = $this->getTemplateRenderer()->renderString($this->getTemplate(), $values);
}
return $content;
}
示例3:
function it_asks_confirmation_if_spec_already_exists($io, $tpl, $fs, ResourceInterface $resource)
{
$resource->getSpecName()->willReturn('App');
$resource->getSpecFilename()->willReturn('/project/spec/Acme/App.php');
$resource->getSpecNamespace()->willReturn('spec\\Acme');
$resource->getSrcClassname()->willReturn('Acme\\App');
$fs->pathExists('/project/spec/Acme/App.php')->willReturn(true);
$io->askConfirmation(Argument::type('string'), false)->willReturn(false);
$fs->putFileContents(Argument::cetera())->shouldNotBeCalled();
$this->generate($resource);
}
示例4: generate
public function generate(ResourceInterface $resource, array $data = array())
{
$filepath = $resource->getSpecFilename();
if ($this->filesystem->pathExists($filepath)) {
$message = sprintf('File "%s" already exists. Overwrite?', basename($filepath));
if (!$this->io->askConfirmation($message, false)) {
return;
}
$this->io->writeln();
}
$path = dirname($filepath);
if (!$this->filesystem->isDirectory($path)) {
$this->filesystem->makeDirectory($path);
}
$values = array('%filepath%' => $filepath, '%name%' => $resource->getSpecName(), '%namespace%' => $resource->getSpecNamespace(), '%subject%' => $resource->getSrcClassname());
if (!($content = $this->templates->render('controller_specification', $values))) {
$content = $this->templates->renderString(file_get_contents(__DIR__ . '/templates/controller_spec.template'), $values);
}
$this->filesystem->putFileContents($filepath, $content);
$this->io->writeln(sprintf("<info>ControllerSpecification for <value>%s</value> created in <value>'%s'</value>.</info>\n", $resource->getSrcClassname(), $filepath));
}
示例5: renderTemplate
/**
* @param ResourceInterface $resource
* @param string $filepath
*
* @return string
*/
protected function renderTemplate(ResourceInterface $resource, $filepath)
{
$values = array('%filepath%' => $filepath, '%name%' => $resource->getSpecName(), '%namespace%' => $resource->getSpecNamespace(), '%subject%' => $resource->getSrcClassname(), '%command%' => $this->commandName ? $this->getCommandExample() : '', '%commandImport%' => $this->commandName ? "\nuse {$this->commandName};" : '');
$content = $this->getTemplateRenderer()->renderString($this->getTemplate(), $values);
return $content;
}