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


PHP Generator::sentence方法代码示例

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


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

示例1: getLocalizedRandomLabels

 /**
  * Get localized random labels
  *
  * @return array
  */
 protected function getLocalizedRandomLabels()
 {
     $locales = $this->getLocales();
     $labels = [];
     foreach ($locales as $locale) {
         $labels[$locale->getCode()] = $this->faker->sentence(2);
     }
     return $labels;
 }
开发者ID:norfil,项目名称:DataGeneratorBundle,代码行数:14,代码来源:AttributeGroupGenerator.php

示例2: testSave

 /**
  * @covers \Glue\Storage\Blob::save
  */
 public function testSave()
 {
     $data = $this->faker->sentence();
     $result = $this->blob->save($data);
     $this->assertNotEquals(false, $result);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('0', $result);
     $this->assertArrayHasKey('1', $result);
     $this->assertEquals(strlen($data), $result[1]);
 }
开发者ID:iborodikhin,项目名称:php-glue,代码行数:13,代码来源:BlobTest.php

示例3: __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('description', function (Options $options) {
         return $this->faker->sentence();
     })->setDefault('gateway', 'offline')->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('enabled', 'bool');
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:19,代码来源:PaymentMethodExampleFactory.php

示例4: __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('code', function (Options $options) {
         return StringInflector::nameToCode($options['name']);
     })->setDefault('name', function (Options $options) {
         return $this->faker->words(3, true);
     })->setDefault('description', function (Options $options) {
         return $this->faker->sentence();
     })->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'))->setDefined('shipping_category')->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' => $this->faker->randomNumber(4)]];
     });
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:23,代码来源:ShippingMethodExampleFactory.php

示例5: generateValueData

 /**
  * Generate value content based on backend type
  *
  * @param AbstractAttribute $attribute
  * @param string            $key
  *
  * @return string
  */
 protected function generateValueData(AbstractAttribute $attribute, $key)
 {
     $data = "";
     if (isset($this->forcedValues[$attribute->getCode()])) {
         return $this->forcedValues[$attribute->getCode()];
     }
     switch ($attribute->getBackendType()) {
         case "varchar":
             $validationRule = $attribute->getValidationRule();
             switch ($validationRule) {
                 case 'url':
                     $data = $this->faker->url();
                     break;
                 default:
                     $data = $this->faker->sentence();
                     break;
             }
             break;
         case "text":
             $data = $this->faker->sentence();
             break;
         case "date":
             $data = $this->faker->dateTimeBetween($attribute->getDateMin(), $attribute->getDateMax());
             $data = $data->format('Y-m-d');
             break;
         case "metric":
         case "decimal":
         case "prices":
             if ($attribute->getBackendType() && preg_match('/-' . self::METRIC_UNIT . '$/', $key)) {
                 $data = $attribute->getDefaultMetricUnit();
             } else {
                 $min = $attribute->getNumberMin() != null ? $attribute->getNumberMin() : self::DEFAULT_NUMBER_MIN;
                 $max = $attribute->getNumberMax() != null ? $attribute->getNumberMax() : self::DEFAULT_NUMBER_MAX;
                 $decimals = $attribute->isDecimalsAllowed() ? self::DEFAULT_NB_DECIMALS : 0;
                 $data = $this->faker->randomFloat($decimals, $min, $max);
             }
             break;
         case "boolean":
             $data = $this->faker->boolean() ? "1" : "0";
             break;
         case "option":
         case "options":
             $options = [];
             foreach ($attribute->getOptions() as $option) {
                 $options[] = $option;
             }
             $option = $this->faker->randomElement($options);
             if (is_object($option)) {
                 $data = $option->getCode();
             }
             break;
         default:
             $data = '';
             break;
     }
     return (string) $data;
 }
开发者ID:norfil,项目名称:DataGeneratorBundle,代码行数:65,代码来源:AssociationCsvGenerator.php

示例6: 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('description', function (Options $options) {
         return $this->faker->sentence();
     })->setDefault('gateway', 'offline')->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setDefault('channels', LazyOption::all($this->channelRepository))->setAllowedTypes('channels', 'array')->setNormalizer('channels', LazyOption::findBy($this->channelRepository, 'code'))->setAllowedTypes('enabled', 'bool');
 }
开发者ID:sylius,项目名称:sylius,代码行数:15,代码来源:PaymentMethodExampleFactory.php

示例7: load

 public function load(ObjectManager $manager)
 {
     $faker = new Faker\Generator();
     $faker->addProvider(new Faker\Provider\en_US\Text($faker));
     $faker->addProvider(new Faker\Provider\Lorem($faker));
     for ($i = 1; $i <= 100; $i++) {
         $post = new Post();
         $post->setTitle($faker->sentence(4));
         $post->setBody($faker->realText(500));
         $manager->persist($post);
     }
     $manager->flush();
 }
开发者ID:jonafrank,项目名称:symfonyBlogSearch,代码行数:13,代码来源:LoadPostData.php

示例8: resolveConfigType

 private function resolveConfigType($config)
 {
     switch ($config['type']) {
         case "url":
             return $this->faker->url;
         case "image":
             $width = isset($config['options']['width']) ? $config['options']['width'] : 800;
             $height = isset($config['options']['height']) ? $config['options']['height'] : 400;
             return $this->faker->imageUrl($width, $height);
         case "page_select":
             $page = ['title' => $this->faker->sentence(), 'body' => $this->faker->text(6000), 'slug' => $this->faker->slug, 'created' => $this->faker->date()];
             return $page;
         case "product_category_select":
         case "collection_select":
             $category = ["name" => $this->faker->word, "slug" => $this->faker->slug];
             return $category;
         case "product_select":
             return $this->tdk->makeProduct();
         default:
             return $this->faker->word;
     }
 }
开发者ID:pasls,项目名称:tdk,代码行数:22,代码来源:ConfigManager.php

示例9: configureOptions

 /**
  * {@inheritdoc}
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefault('code', function (Options $options) {
         return StringInflector::nameToCode($options['name']);
     })->setDefault('name', $this->faker->words(3, true))->setDefault('description', $this->faker->sentence())->setDefault('usage_limit', null)->setDefault('coupon_based', false)->setDefault('exclusive', $this->faker->boolean(25))->setDefault('priority', 0)->setDefault('starts_at', null)->setAllowedTypes('starts_at', ['null', 'string'])->setDefault('ends_at', null)->setAllowedTypes('ends_at', ['null', 'string'])->setDefault('channels', LazyOption::all($this->channelRepository))->setAllowedTypes('channels', 'array')->setNormalizer('channels', LazyOption::findBy($this->channelRepository, 'code'))->setDefined('rules')->setNormalizer('rules', function (Options $options, array $rules) {
         if (empty($rules)) {
             return [[]];
         }
         return $rules;
     })->setDefined('actions')->setNormalizer('actions', function (Options $options, array $actions) {
         if (empty($actions)) {
             return [[]];
         }
         return $actions;
     });
 }
开发者ID:NeverResponse,项目名称:Sylius,代码行数:19,代码来源:PromotionExampleFactory.php

示例10: 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('description', function (Options $options) {
         return $this->faker->sentence();
     })->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('enabled', 'bool')->setDefault('zone', LazyOption::randomOne($this->zoneRepository))->setAllowedTypes('zone', ['null', 'string', ZoneInterface::class])->setNormalizer('zone', LazyOption::findOneBy($this->zoneRepository, 'code'))->setDefined('shipping_category')->setAllowedTypes('shipping_category', ['null', 'string', ShippingCategoryInterface::class])->setNormalizer('shipping_category', LazyOption::findOneBy($this->shippingCategoryRepository, 'code'))->setDefault('calculator', function (Options $options) {
         $configuration = [];
         /** @var ChannelInterface $channel */
         foreach ($options['channels'] as $channel) {
             $configuration[$channel->getCode()] = ['amount' => $this->faker->randomNumber(4)];
         }
         return ['type' => DefaultCalculators::FLAT_RATE, 'configuration' => $configuration];
     })->setDefault('channels', LazyOption::all($this->channelRepository))->setAllowedTypes('channels', 'array')->setNormalizer('channels', LazyOption::findBy($this->channelRepository, 'code'));
 }
开发者ID:sylius,项目名称:sylius,代码行数:22,代码来源:ShippingMethodExampleFactory.php

示例11: getDummyData

 public function getDummyData(Generator $faker, array $customValues = array())
 {
     return ['title' => $faker->sentence(), 'status' => $faker->randomElement(['open', 'open', 'closed']), 'user_id' => $this->getRandom('User')->id];
 }
开发者ID:ariels78,项目名称:TeachMe,代码行数:4,代码来源:TicketTableSeeder.php

示例12: getDummyData

 public function getDummyData(Generator $faker)
 {
     return ["title" => $faker->sentence(), "status" => $faker->randomElement(["open", "closed"]), "user_id" => $this->getRandomId("User")];
 }
开发者ID:fgpayano,项目名称:laravel_teachme,代码行数:4,代码来源:TicketTableSeeder.php

示例13: getSentence

 /**
  * @param int $wordCount
  * @return string
  */
 public function getSentence($wordCount)
 {
     return $this->faker->sentence(max($wordCount, 1));
 }
开发者ID:shobcheye,项目名称:sw-cli-tools,代码行数:8,代码来源:RandomDataProvider.php

示例14: getDummyData

 public function getDummyData(Generator $faker, array $valoresPersonalizados = array())
 {
     return ['titulo' => $faker->sentence(), 'estado' => $faker->randomElement(['abierto', 'cerrado']), 'user_id' => $this->getRandom('User')->id];
 }
开发者ID:alzort,项目名称:ByteCode-es-Ticket,代码行数:4,代码来源:TicketTableSeeder.php

示例15: newApiRequest

 /**
  * @param string $endpoint
  * @return RequestInterface
  */
 private function newApiRequest($endpoint)
 {
     $request = (new Request($endpoint))->withMethod('POST')->withHeader('Content-Type', 'application/x-www-form-urlencoded');
     $request->getBody()->write(http_build_query(['data' => $this->faker->sentence(rand(3, 6))]));
     return $request;
 }
开发者ID:php-school,项目名称:learn-you-php,代码行数:10,代码来源:DependencyHeaven.php


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