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


PHP Generator::paragraphs方法代码示例

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


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

示例1: getArgs

 /**
  * @return array
  */
 public function getArgs()
 {
     $path = $this->getTemporaryPath();
     $paragraphs = $this->faker->paragraphs(rand(5, 50), true);
     $this->filesystem->dumpFile($path, $paragraphs);
     return [$path];
 }
开发者ID:php-school,项目名称:learn-you-php,代码行数:10,代码来源:MyFirstIo.php

示例2: __construct

 /**
  * @param FactoryInterface $staticContentFactory
  */
 public function __construct(FactoryInterface $staticContentFactory)
 {
     $this->staticContentFactory = $staticContentFactory;
     $this->faker = \Faker\Factory::create();
     $this->optionsResolver = (new OptionsResolver())->setDefault('title', function (Options $options) {
         return $this->faker->words(3, true);
     })->setDefault('name', function (Options $options) {
         return StringInflector::nameToCode($options['title']);
     })->setDefault('body', function (Options $options) {
         return $this->faker->paragraphs(4, true);
     })->setDefault('publishable', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('publishable', 'bool');
 }
开发者ID:loic425,项目名称:Sylius,代码行数:17,代码来源:StaticContentExampleFactory.php

示例3: __construct

 /**
  * @param FactoryInterface $productFactory
  * @param FactoryInterface $productVariantFactory
  * @param ProductVariantGeneratorInterface $variantGenerator
  * @param FactoryInterface $productAttributeValueFactory
  * @param FactoryInterface $productImageFactory
  * @param ImageUploaderInterface $imageUploader
  * @param SlugGeneratorInterface $slugGenerator
  * @param RepositoryInterface $taxonRepository
  * @param RepositoryInterface $productAttributeRepository
  * @param RepositoryInterface $productOptionRepository
  * @param RepositoryInterface $channelRepository
  * @param RepositoryInterface $localeRepository
  */
 public function __construct(FactoryInterface $productFactory, FactoryInterface $productVariantFactory, ProductVariantGeneratorInterface $variantGenerator, FactoryInterface $productAttributeValueFactory, FactoryInterface $productImageFactory, ImageUploaderInterface $imageUploader, SlugGeneratorInterface $slugGenerator, RepositoryInterface $taxonRepository, RepositoryInterface $productAttributeRepository, RepositoryInterface $productOptionRepository, RepositoryInterface $channelRepository, RepositoryInterface $localeRepository)
 {
     $this->productFactory = $productFactory;
     $this->productVariantFactory = $productVariantFactory;
     $this->variantGenerator = $variantGenerator;
     $this->productImageFactory = $productImageFactory;
     $this->imageUploader = $imageUploader;
     $this->slugGenerator = $slugGenerator;
     $this->localeRepository = $localeRepository;
     $this->faker = \Faker\Factory::create();
     $this->optionsResolver = (new OptionsResolver())->setDefault('name', function (Options $options) {
         return $this->faker->words(3, true);
     })->setDefault('code', function (Options $options) {
         return StringInflector::nameToCode($options['name']);
     })->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('enabled', 'bool')->setDefault('short_description', function (Options $options) {
         return $this->faker->paragraph;
     })->setDefault('description', function (Options $options) {
         return $this->faker->paragraphs(3, true);
     })->setDefault('main_taxon', LazyOption::randomOne($taxonRepository))->setAllowedTypes('main_taxon', ['null', 'string', TaxonInterface::class])->setNormalizer('main_taxon', LazyOption::findOneBy($taxonRepository, 'code'))->setDefault('taxons', LazyOption::randomOnes($taxonRepository, 3))->setAllowedTypes('taxons', 'array')->setNormalizer('taxons', LazyOption::findBy($taxonRepository, 'code'))->setDefault('channels', LazyOption::randomOnes($channelRepository, 3))->setAllowedTypes('channels', 'array')->setNormalizer('channels', LazyOption::findBy($channelRepository, 'code'))->setDefault('product_attributes', [])->setAllowedTypes('product_attributes', 'array')->setNormalizer('product_attributes', function (Options $options, array $productAttributes) use($productAttributeRepository, $productAttributeValueFactory) {
         $productAttributesValues = [];
         foreach ($productAttributes as $code => $value) {
             /** @var ProductAttributeInterface $productAttribute */
             $productAttribute = $productAttributeRepository->findOneBy(['code' => $code]);
             Assert::notNull($productAttribute);
             /** @var ProductAttributeValueInterface $productAttributeValue */
             $productAttributeValue = $productAttributeValueFactory->createNew();
             $productAttributeValue->setAttribute($productAttribute);
             $productAttributeValue->setValue($value ?: $this->getRandomValueForProductAttribute($productAttribute));
             $productAttributesValues[] = $productAttributeValue;
         }
         return $productAttributesValues;
     })->setDefault('product_options', [])->setAllowedTypes('product_options', 'array')->setNormalizer('product_options', LazyOption::findBy($productOptionRepository, 'code'))->setDefault('images', [])->setAllowedTypes('images', 'array');
 }
开发者ID:loic425,项目名称:Sylius,代码行数:49,代码来源:ProductExampleFactory.php

示例4: configureOptions

 /**
  * {@inheritdoc}
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefault('name', function (Options $options) {
         return $this->faker->words(3, true);
     })->setDefault('code', function (Options $options) {
         return StringInflector::nameToCode($options['name']);
     })->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('enabled', 'bool')->setDefault('short_description', function (Options $options) {
         return $this->faker->paragraph;
     })->setDefault('description', function (Options $options) {
         return $this->faker->paragraphs(3, true);
     })->setDefault('main_taxon', LazyOption::randomOne($this->taxonRepository))->setAllowedTypes('main_taxon', ['null', 'string', TaxonInterface::class])->setNormalizer('main_taxon', LazyOption::findOneBy($this->taxonRepository, 'code'))->setDefault('taxons', LazyOption::randomOnes($this->taxonRepository, 3))->setAllowedTypes('taxons', 'array')->setNormalizer('taxons', LazyOption::findBy($this->taxonRepository, 'code'))->setDefault('channels', LazyOption::randomOnes($this->channelRepository, 3))->setAllowedTypes('channels', 'array')->setNormalizer('channels', LazyOption::findBy($this->channelRepository, 'code'))->setDefault('variant_selection_method', ProductInterface::VARIANT_SELECTION_MATCH)->setAllowedValues('variant_selection_method', [ProductInterface::VARIANT_SELECTION_MATCH, ProductInterface::VARIANT_SELECTION_CHOICE])->setDefault('product_attributes', [])->setAllowedTypes('product_attributes', 'array')->setNormalizer('product_attributes', function (Options $options, array $productAttributes) {
         $productAttributesValues = [];
         foreach ($productAttributes as $code => $value) {
             /** @var ProductAttributeInterface $productAttribute */
             $productAttribute = $this->productAttributeRepository->findOneBy(['code' => $code]);
             Assert::notNull($productAttribute);
             /** @var ProductAttributeValueInterface $productAttributeValue */
             $productAttributeValue = $this->productAttributeValueFactory->createNew();
             $productAttributeValue->setAttribute($productAttribute);
             $productAttributeValue->setValue($value ?: $this->getRandomValueForProductAttribute($productAttribute));
             $productAttributesValues[] = $productAttributeValue;
         }
         return $productAttributesValues;
     })->setDefault('product_options', [])->setAllowedTypes('product_options', 'array')->setNormalizer('product_options', LazyOption::findBy($this->productOptionRepository, 'code'))->setDefault('images', [])->setAllowedTypes('images', 'array');
 }
开发者ID:sylius,项目名称:sylius,代码行数:30,代码来源:ProductExampleFactory.php

示例5: createProjectPhaseDocument

 /**
  * Create a random ProjectPhaseDocument.
  *
  * @param int VisualAppeal\Connect\ProjectPhase $projectPhase (Default: null, newly created)
  *
  * @return VisualAppeal\Connect\ProjectPhaseDocument
  */
 public function createProjectPhaseDocument($projectPhase = null)
 {
     $projectPhase = $projectPhase ?: $this->createProjectPhase();
     return \VisualAppeal\Connect\ProjectPhaseDocument::create(['project_phase_id' => $projectPhase->id, 'title' => implode(' ', $this->faker->words(4)), 'content' => implode("\n", $this->faker->paragraphs(3)), 'type' => 'published']);
 }
开发者ID:rafaelvieiras,项目名称:connect,代码行数:12,代码来源:TestCase.php


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