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


PHP Generator::words方法代码示例

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


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

示例1: __construct

 /**
  * @param FactoryInterface $taxRateFactory
  * @param RepositoryInterface $zoneRepository
  * @param RepositoryInterface $taxCategoryRepository
  */
 public function __construct(FactoryInterface $taxRateFactory, RepositoryInterface $zoneRepository, RepositoryInterface $taxCategoryRepository)
 {
     $this->taxRateFactory = $taxRateFactory;
     $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('amount', function (Options $options) {
         return $this->faker->randomFloat(2, 0, 1);
     })->setAllowedTypes('amount', 'float')->setDefault('included_in_price', function (Options $options) {
         return $this->faker->boolean();
     })->setAllowedTypes('included_in_price', 'bool')->setDefault('calculator', 'default')->setDefault('zone', LazyOption::randomOne($zoneRepository))->setAllowedTypes('zone', ['null', 'string', ZoneInterface::class])->setNormalizer('zone', LazyOption::findOneBy($zoneRepository, 'code'))->setDefault('tax_category', LazyOption::randomOne($taxCategoryRepository))->setAllowedTypes('tax_category', ['null', 'string', TaxCategoryInterface::class])->setNormalizer('tax_category', LazyOption::findOneBy($taxCategoryRepository, 'code'));
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:19,代码来源:TaxRateExampleFactory.php

示例2: tags

 /**
  * Generate an array of tags
  *
  * @param   int $prefixChance   Percent chance the result will have a prefix assigned
  * @param   int $min            Minimum number of tags
  * @param   int $max            Maximum number of tags
  * @return  array
  */
 public function tags($prefixChance = 25, $min = 1, $max = 7)
 {
     $tags = $this->faker->words(mt_rand($min, $max));
     $prefix = mt_rand(0, 100) < $prefixChance ? array_rand($tags) : NULL;
     // 25% chance to add a tag prefix
     return array('tags' => $tags, 'prefix' => $prefix);
 }
开发者ID:alobimday,项目名称:IPS-Faker,代码行数:15,代码来源:Generator.php

示例3: 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']);
     });
 }
开发者ID:NeverResponse,项目名称:Sylius,代码行数:11,代码来源:ProductAssociationTypeExampleFactory.php

示例4: __construct

 /**
  * @param FactoryInterface $routeFactory
  */
 public function __construct(FactoryInterface $routeFactory, RepositoryInterface $staticContentRepository)
 {
     $this->routeFactory = $routeFactory;
     $this->faker = \Faker\Factory::create();
     $this->optionsResolver = (new OptionsResolver())->setDefault('name', function (Options $options) {
         return StringInflector::nameToCode($this->faker->words(3, true));
     })->setDefault('content', LazyOption::randomOne($staticContentRepository))->setAllowedTypes('content', ['string', StaticContent::class])->setNormalizer('content', LazyOption::findOneBy($staticContentRepository, 'name'));
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:11,代码来源:RouteExampleFactory.php

示例5: 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('type', function (Options $options) {
         return $this->faker->randomElement(array_keys($this->attributeTypes));
     })->setAllowedValues('type', array_keys($this->attributeTypes));
 }
开发者ID:sylius,项目名称:sylius,代码行数:13,代码来源:ProductAttributeExampleFactory.php

示例6: __construct

 /**
  * @param FactoryInterface $productArchetypeFactory
  * @param RepositoryInterface $productOptionRepository
  * @param RepositoryInterface $productAttributeRepository
  * @param RepositoryInterface $localeRepository
  */
 public function __construct(FactoryInterface $productArchetypeFactory, RepositoryInterface $productOptionRepository, RepositoryInterface $productAttributeRepository, RepositoryInterface $localeRepository)
 {
     $this->productArchetypeFactory = $productArchetypeFactory;
     $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('product_options', LazyOption::randomOnes($productOptionRepository, 2))->setAllowedTypes('product_options', 'array')->setNormalizer('product_options', LazyOption::findBy($productOptionRepository, 'code'))->setDefault('product_attributes', LazyOption::randomOnes($productAttributeRepository, 2))->setAllowedTypes('product_attributes', 'array')->setNormalizer('product_attributes', LazyOption::findBy($productAttributeRepository, 'code'));
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:17,代码来源:ProductArchetypeExampleFactory.php

示例7: __construct

 /**
  * @param FactoryInterface $shippingCategoryFactory
  */
 public function __construct(FactoryInterface $shippingCategoryFactory)
 {
     $this->shippingCategoryFactory = $shippingCategoryFactory;
     $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('description', function (Options $options) {
         return $this->faker->paragraph;
     });
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:15,代码来源:ShippingCategoryExampleFactory.php

示例8: configureOptions

 /**
  * {@inheritdoc}
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefault('code', function (Options $options) {
         return StringInflector::nameToCode($options['name']);
     })->setDefault('name', function (Options $options) {
         return $this->faker->words(3, true);
     })->setDefault('amount', function (Options $options) {
         return $this->faker->randomFloat(2, 0, 0.4);
     })->setAllowedTypes('amount', 'float')->setDefault('included_in_price', function (Options $options) {
         return $this->faker->boolean();
     })->setAllowedTypes('included_in_price', 'bool')->setDefault('calculator', 'default')->setDefault('zone', LazyOption::randomOne($this->zoneRepository))->setAllowedTypes('zone', ['null', 'string', ZoneInterface::class])->setNormalizer('zone', LazyOption::findOneBy($this->zoneRepository, 'code'))->setDefault('category', LazyOption::randomOne($this->taxCategoryRepository))->setAllowedTypes('category', ['null', 'string', TaxCategoryInterface::class])->setNormalizer('category', LazyOption::findOneBy($this->taxCategoryRepository, 'code'));
 }
开发者ID:sylius,项目名称:sylius,代码行数:15,代码来源:TaxRateExampleFactory.php

示例9: __construct

 /**
  * @param AttributeFactoryInterface $productAttributeFactory
  * @param RepositoryInterface $localeRepository
  * @param array $attributeTypes
  */
 public function __construct(AttributeFactoryInterface $productAttributeFactory, RepositoryInterface $localeRepository, array $attributeTypes)
 {
     $this->productAttributeFactory = $productAttributeFactory;
     $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('type', function (Options $options) use($attributeTypes) {
         return $this->faker->randomElement(array_keys($attributeTypes));
     })->setAllowedValues('type', array_keys($attributeTypes));
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:18,代码来源:ProductAttributeExampleFactory.php

示例10: __construct

 /**
  * @param FactoryInterface $paymentMethodFactory
  * @param RepositoryInterface $localeRepository
  */
 public function __construct(FactoryInterface $paymentMethodFactory, RepositoryInterface $localeRepository)
 {
     $this->paymentMethodFactory = $paymentMethodFactory;
     $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('gateway', 'offline')->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('enabled', 'bool');
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:17,代码来源:PaymentMethodExampleFactory.php

示例11: __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

示例12: __construct

 /**
  * @param FactoryInterface $taxonFactory
  * @param TaxonRepositoryInterface $taxonRepository
  * @param ObjectManager $taxonManager
  * @param RepositoryInterface $localeRepository
  */
 public function __construct(FactoryInterface $taxonFactory, TaxonRepositoryInterface $taxonRepository, ObjectManager $taxonManager, RepositoryInterface $localeRepository)
 {
     $this->taxonFactory = $taxonFactory;
     $this->taxonRepository = $taxonRepository;
     $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('description', function (Options $options) {
         return $this->faker->paragraph;
     })->setDefault('children', [])->setAllowedTypes('children', ['array']);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:20,代码来源:TaxonExampleFactory.php

示例13: __construct

 /**
  * @param FactoryInterface $shippingMethodFactory
  * @param RepositoryInterface $zoneRepository
  * @param RepositoryInterface $shippingCategoryRepository
  * @param RepositoryInterface $localeRepository
  */
 public function __construct(FactoryInterface $shippingMethodFactory, RepositoryInterface $zoneRepository, RepositoryInterface $shippingCategoryRepository, RepositoryInterface $localeRepository)
 {
     $this->shippingMethodFactory = $shippingMethodFactory;
     $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('zone', LazyOption::randomOne($zoneRepository))->setAllowedTypes('zone', ['null', 'string', ZoneInterface::class])->setNormalizer('zone', LazyOption::findOneBy($zoneRepository, 'code'))->setDefault('shipping_category', LazyOption::randomOne($shippingCategoryRepository))->setAllowedTypes('shipping_category', ['null', 'string', ShippingCategoryInterface::class])->setNormalizer('shipping_category', LazyOption::findOneBy($shippingCategoryRepository, 'code'))->setDefault('calculator', function (Options $options) {
         return ['type' => DefaultCalculators::FLAT_RATE, 'configuration' => ['amount' => 4200]];
     });
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:21,代码来源:ShippingMethodExampleFactory.php

示例14: __construct

 /**
  * @param ChannelFactoryInterface $channelFactory
  * @param RepositoryInterface $localeRepository
  * @param RepositoryInterface $currencyRepository
  * @param RepositoryInterface $paymentMethodRepository
  * @param RepositoryInterface $shippingMethodRepository
  */
 public function __construct(ChannelFactoryInterface $channelFactory, RepositoryInterface $localeRepository, RepositoryInterface $currencyRepository, RepositoryInterface $paymentMethodRepository, RepositoryInterface $shippingMethodRepository)
 {
     $this->channelFactory = $channelFactory;
     $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('hostname', function (Options $options) {
         return $options['code'] . '.localhost';
     })->setDefault('color', function (Options $options) {
         return $this->faker->colorName;
     })->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('enabled', 'bool')->setDefault('locales', LazyOption::all($localeRepository))->setAllowedTypes('locales', 'array')->setNormalizer('locales', LazyOption::findBy($localeRepository, 'code'))->setDefault('currencies', LazyOption::all($currencyRepository))->setAllowedTypes('currencies', 'array')->setNormalizer('currencies', LazyOption::findBy($currencyRepository, 'code'))->setDefault('payment_methods', LazyOption::all($paymentMethodRepository))->setAllowedTypes('payment_methods', 'array')->setNormalizer('payment_methods', LazyOption::findBy($paymentMethodRepository, 'code'))->setDefault('shipping_methods', LazyOption::all($shippingMethodRepository))->setAllowedTypes('shipping_methods', 'array')->setNormalizer('shipping_methods', LazyOption::findBy($shippingMethodRepository, 'code'));
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:23,代码来源:ChannelExampleFactory.php

示例15: generateProducts

 public static function generateProducts(\Faker\Generator $generator)
 {
     $title_words = $generator->words(mt_rand(2, 5));
     $title = implode(' ', $title_words);
     $price = mt_rand(1, 10000);
     return array('title' => $title, 'price' => $price);
 }
开发者ID:boliev,项目名称:tstask,代码行数:7,代码来源:ProductsCollection.php


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