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


PHP Generator::realText方法代码示例

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


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

示例1: testTextMinLength

 /**
  * @expectedException \InvalidArgumentException
  */
 public function testTextMinLength()
 {
     $generator = new Generator();
     $generator->addProvider(new Text($generator));
     $generator->seed(0);
     $generator->realText(9);
 }
开发者ID:diandianxiyu,项目名称:Yii2Api,代码行数:10,代码来源:TextTest.php

示例2: generate

 /**
  * Generate products.
  *
  * ## Options
  *
  * [--file=<file>]
  * : Specify which files to used. By default pulls random zips from DB.
  *
  * [--count=<count>]
  * : How many products to generate. Default: 15
  *
  * @param $args
  * @param $assoc_args
  */
 public function generate($args, $assoc_args)
 {
     $count = \WP_CLI\Utils\get_flag_value($assoc_args, 'count', 15);
     if (!\WP_CLI\Utils\get_flag_value($assoc_args, 'file')) {
         /**
          * @var \wpdb $wpdb
          */
         global $wpdb;
         $results = $wpdb->get_results($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment'\n\t\t\t\t AND post_mime_type = 'application/zip' LIMIT %d", $count));
         $files = array();
         foreach ($results as $result) {
             $files[] = $result->ID;
         }
     } else {
         if (get_post_type($assoc_args['file']) != 'attachment') {
             WP_CLI::error("Invalid file post type.");
         }
         $files = array($assoc_args['file']);
     }
     if (empty($files)) {
         WP_CLI::error('No files exist.');
     }
     $notify = \WP_CLI\Utils\make_progress_bar('Generating products.', $count);
     $limits = array('-', '2', '2', '5', '5', '10');
     for ($i = 0; $i < $count; $i++) {
         $title = $this->faker->catchPhrase . ' software';
         $price = itelic_purebell(44, 199, 45);
         $price = floatval(intval($price));
         $index = array_rand($files);
         $file = get_post($files[$index]);
         try {
             $file = itelic_rename_file($file, $title . '-1.0.zip');
         } catch (InvalidArgumentException $e) {
             WP_CLI::error($e->getMessage());
         }
         $params = array('description' => $this->faker->realText(), 'limit' => $limits[array_rand($limits)], 'file' => $file->ID);
         $recurring = array(array('interval' => 'month', 'count' => 1, 'frequency' => 10), array('interval' => 'month', 'count' => 6, 'frequency' => 20), array('interval' => 'none', 'frequency' => 30), array('interval' => 'year', 'count' => 1, 'frequency' => 100));
         $rand = rand(0, 100);
         foreach ($recurring as $option) {
             if ($rand <= $option['frequency']) {
                 if ($option['interval'] != 'none') {
                     $params['interval'] = $option['interval'];
                     $params['interval-count'] = $option['count'];
                 }
                 break;
             }
         }
         $result = $this->create_product($title, $price, $params);
         if (is_wp_error($result)) {
             WP_CLI::error($result);
         }
         $notify->tick();
     }
     $notify->finish();
 }
开发者ID:pemiu01,项目名称:exchange-addon-licensing,代码行数:69,代码来源:Product.php

示例3: createComments

 /**
  * @param int $count
  * @param Video[] $videos
  * @param User[] $users
  * @param Repository $repo
  * @throws \Exception
  */
 protected function createComments($count, $videos, $users, Repository $repo)
 {
     $this->out->writeln(Comment::class);
     /** @var ProgressHelper $progress */
     $progress = $this->getHelperSet()->get('progress');
     $progress->start($this->out, count($videos) * $count);
     foreach ($videos as $video) {
         $comments = [];
         for ($i = 0; $i < $count; ++$i) {
             $comment = new Comment();
             $comment->author = $this->faker->randomElement($users);
             $comment->text = $this->faker->realText(100);
             $comment->inReplyTo = $this->faker->optional(0.25)->randomElement($comments);
             $video->comments->add($comment);
             $comments[] = $comment;
             $progress->advance();
         }
         $repo->persist($video);
     }
     $progress->finish();
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:28,代码来源:Fake.php

示例4: 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


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