本文整理汇总了PHP中PhpSpec\Locator\ResourceInterface::getSrcNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceInterface::getSrcNamespace方法的具体用法?PHP ResourceInterface::getSrcNamespace怎么用?PHP ResourceInterface::getSrcNamespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpSpec\Locator\ResourceInterface
的用法示例。
在下文中一共展示了ResourceInterface::getSrcNamespace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderTemplate
/**
* @param ResourceInterface $resource
* @param string $filepath
*
* @return string
*/
protected function renderTemplate(ResourceInterface $resource, $filepath)
{
$values = array('%filepath%' => $filepath, '%name%' => $resource->getName(), '%namespace%' => $resource->getSrcNamespace(), '%namespace_block%' => '' !== $resource->getSrcNamespace() ? sprintf("\n\nnamespace %s;", $resource->getSrcNamespace()) : '');
if (!($content = $this->getTemplateRenderer()->render('class', $values))) {
$content = $this->getTemplateRenderer()->renderString($this->getTemplate(), $values);
}
return $content;
}
示例2: let
function let(ResourceInterface $resource)
{
$resource->getSrcNamespace()->willReturn('Foo');
$resource->getSpecNamespace()->willReturn('spec/Foo');
$resource->getName()->willReturn('Bar');
$this->beConstructedWith($resource, self::CONTENT);
}
示例3:
function it_asks_confirmation_if_class_already_exists($io, $tpl, $fs, ResourceInterface $resource)
{
$resource->getName()->willReturn('App');
$resource->getSrcFilename()->willReturn('/project/src/Acme/App.php');
$resource->getSrcNamespace()->willReturn('Acme');
$resource->getSrcClassname()->willReturn('Acme\\App');
$fs->pathExists('/project/src/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->getSrcFilename();
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->getName(), '%namespace%' => $resource->getSrcNamespace(), '%namespace_block%' => '' !== $resource->getSrcNamespace() ? sprintf("\n\nnamespace %s;", $resource->getSrcNamespace()) : '');
if (!($content = $this->templates->render('wp_class', $values))) {
$content = $this->templates->renderString(file_get_contents(__DIR__ . '/templates/generic_class.template'), $values);
}
$this->filesystem->putFileContents($filepath, $content);
$this->io->writeln(sprintf("<info>WP class <value>%s</value> created in <value>'%s'</value>.</info>\n", $resource->getSrcClassname(), $filepath));
}
示例5:
function it_records_that_class_was_created_in_executioncontext(ResourceInterface $resource, ExecutionContextInterface $executionContext)
{
$resource->getName()->willReturn('App');
$resource->getSrcFilename()->willReturn('/project/src/Acme/App.php');
$resource->getSrcNamespace()->willReturn('Acme');
$resource->getSrcClassname()->willReturn('Acme\\App');
$this->generate($resource);
$executionContext->addGeneratedType('Acme\\App')->shouldHaveBeenCalled();
}
示例6: modifySrcContent
/**
* @param ResourceInterface $oldResource
* @param ResourceInterface $newResource
*
* @return string
*/
private function modifySrcContent(ResourceInterface $oldResource, ResourceInterface $newResource)
{
return $this->modifyResourceContent($oldResource, file_get_contents($oldResource->getSrcFilename()), $newResource->getSrcNamespace(), $newResource->getName());
}
示例7: setNamespace
/**
* @param $namespace
*/
public function setNamespace($namespace)
{
$this->content = preg_replace(sprintf('/namespace (%s|%s)/', preg_quote($this->resource->getSrcNamespace(), '/'), preg_quote($this->resource->getSpecNamespace(), '/')), sprintf('namespace %s', $namespace), $this->content);
}