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