当前位置: 首页>>代码示例>>PHP>>正文


PHP ResourceInterface::getName方法代码示例

本文整理汇总了PHP中PhpSpec\Locator\ResourceInterface::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceInterface::getName方法的具体用法?PHP ResourceInterface::getName怎么用?PHP ResourceInterface::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhpSpec\Locator\ResourceInterface的用法示例。


在下文中一共展示了ResourceInterface::getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

    function it_generates_static_constructor_method_from_resource($io, $tpl, $fs, ResourceInterface $resource)
    {
        $codeWithoutMethod = <<<CODE
<?php

namespace Acme;

class App
{
}

CODE;
        $codeWithMethod = <<<CODE
<?php

namespace Acme;

class App
{
METHOD
}

CODE;
        $values = array('%methodName%' => 'setName', '%arguments%' => '$argument1', '%returnVar%' => '$app', '%className%' => 'App', '%constructorArguments%' => '');
        $resource->getSrcFilename()->willReturn('/project/src/Acme/App.php');
        $resource->getSrcClassname()->willReturn('Acme\\App');
        $resource->getName()->willReturn('App');
        $tpl->render('named_constructor_create_object', $values)->willReturn(null);
        $tpl->renderString(Argument::type('string'), $values)->willReturn('METHOD');
        $fs->getFileContents('/project/src/Acme/App.php')->willReturn($codeWithoutMethod);
        $fs->putFileContents('/project/src/Acme/App.php', $codeWithMethod)->shouldBeCalled();
        $this->generate($resource, array('name' => 'setName', 'arguments' => array('jmurphy')));
    }
开发者ID:focuslife,项目名称:v0.1,代码行数:33,代码来源:NamedConstructorGeneratorSpec.php

示例2: let

 function let(ResourceInterface $resource)
 {
     $resource->getSrcNamespace()->willReturn('Foo');
     $resource->getSpecNamespace()->willReturn('spec/Foo');
     $resource->getName()->willReturn('Bar');
     $this->beConstructedWith($resource, self::CONTENT);
 }
开发者ID:mike182uk,项目名称:phpspec-rename,代码行数:7,代码来源:ResourceContentModifierSpec.php

示例3: 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;
 }
开发者ID:franzliedke,项目名称:phpspec,代码行数:14,代码来源:ClassGenerator.php

示例4: 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(), '%subject_class%' => $resource->getName());
     if (!($content = $this->getTemplateRenderer()->render('specification', $values))) {
         $content = $this->getTemplateRenderer()->renderString($this->getTemplate(), $values);
     }
     return $content;
 }
开发者ID:nix9,项目名称:laracasts,代码行数:14,代码来源:SpecificationGenerator.php

示例5: getContent

 /**
  * @param ResourceInterface $resource
  * @param string            $methodName
  * @param array             $arguments
  * @return string
  */
 private function getContent(ResourceInterface $resource, $methodName, $arguments)
 {
     $className = $resource->getName();
     $class = $resource->getSrcClassname();
     $template = new CreateObjectTemplate($this->templates, $methodName, $arguments, $className);
     if (method_exists($class, '__construct')) {
         $template = new ExistingConstructorTemplate($this->templates, $methodName, $arguments, $className, $class);
     }
     return $template->getContent();
 }
开发者ID:franzliedke,项目名称:phpspec,代码行数:16,代码来源:NamedConstructorGenerator.php

示例6:

 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);
 }
开发者ID:kpaxer,项目名称:shcms,代码行数:11,代码来源:ClassGeneratorSpec.php

示例7:

 function it_creates_folder_for_spec_if_needed($io, $tpl, $fs, ResourceInterface $resource)
 {
     $resource->getSpecName()->willReturn('AppAppSpec');
     $resource->getSpecFilename()->willReturn('/project/spec/Acme/AppSpec.php');
     $resource->getSpecNamespace()->willReturn('spec\\Acme');
     $resource->getSrcClassname()->willReturn('Acme\\App');
     $resource->getName()->willReturn('App');
     $fs->pathExists('/project/spec/Acme/AppSpec.php')->willReturn(false);
     $fs->isDirectory('/project/spec/Acme')->willReturn(false);
     $fs->makeDirectory('/project/spec/Acme')->shouldBeCalled();
     $fs->putFileContents('/project/spec/Acme/AppSpec.php', Argument::any())->willReturn(null);
     $this->generate($resource);
 }
开发者ID:manhvu1212,项目名称:videoplatform,代码行数:13,代码来源:SpecificationGeneratorSpec.php

示例8: 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));
 }
开发者ID:sourcerer-mike,项目名称:phpspec-wordpress,代码行数:21,代码来源:WpGenerator.php

示例9:

 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();
 }
开发者ID:manhvu1212,项目名称:videoplatform,代码行数:9,代码来源:ClassGeneratorSpec.php

示例10: supports

 /**
  * @param ResourceInterface $resource
  * @param string            $generation
  * @param array             $data
  *
  * @return boolean
  */
 public function supports(ResourceInterface $resource, $generation, array $data)
 {
     $needle = 'CommandHandler';
     $isHandler = substr($resource->getName(), -strlen($needle)) === $needle;
     return 'specification' === $generation && $isHandler;
 }
开发者ID:eniuz,项目名称:PhpSpecBroadwayExtension,代码行数:13,代码来源:CommandHandlerSpecificationGenerator.php

示例11: modifySpecContent

 /**
  * @param ResourceInterface $oldResource
  * @param ResourceInterface $newResource
  *
  * @return string
  */
 private function modifySpecContent(ResourceInterface $oldResource, ResourceInterface $newResource)
 {
     return $this->modifyResourceContent($oldResource, file_get_contents($oldResource->getSpecFilename()), $newResource->getSpecNamespace(), $newResource->getName());
 }
开发者ID:mike182uk,项目名称:phpspec-rename,代码行数:10,代码来源:ResourceRelocator.php

示例12: setClassName

 /**
  * @param $className
  */
 public function setClassName($className)
 {
     $this->content = preg_replace(sprintf('/class %s/', $this->resource->getName()), sprintf('class %s', $className), $this->content);
 }
开发者ID:mike182uk,项目名称:phpspec-rename,代码行数:7,代码来源:ResourceContentModifier.php


注:本文中的PhpSpec\Locator\ResourceInterface::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。