當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。