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


PHP Generator::dateTimeBetween方法代码示例

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


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

示例1: execute

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $count = $input->getArgument('count');
     $output->writeln(sprintf('<info>Generating %d members</info>', $count));
     for ($i = 1; $i <= $count; $i++) {
         $member = new Member($this->faker->userName, $this->faker->word, new Address('Canada', 'Ontario', $this->faker->gtaCity, $this->faker->postCode), new \DateTime($this->faker->dateTimeBetween('-65 years', 'now - 18 years')->format('Y-m-d')), $this->faker->limits, new Height($this->faker->height), new Weight($this->faker->weight), $this->faker->bodyType, $this->faker->ethnicity, new Email($this->faker->freeEmail));
         $this->members->add($member);
         $output->writeln(sprintf('%s', $member->getUsername()));
     }
     $output->writeln('<info>...done</info>');
 }
开发者ID:hongshuan,项目名称:avid-candidate-challenge-busted,代码行数:17,代码来源:GenerateMembers.php

示例2: generate_customer

 /**
  * Generate a customer.
  *
  * ## Options
  *
  * [--billing]
  * : Generate billing addresses
  *
  * @param array $args
  */
 protected function generate_customer($args)
 {
     $first = $this->faker->firstName;
     $last = $this->faker->lastName;
     $ID = wp_insert_user(array('user_login' => "{$first} {$last}", 'first_name' => $first, 'last_name' => $last, 'user_email' => $this->faker->safeEmail, 'user_registered' => $this->faker->dateTimeBetween('-2 years')->format('Y-m-d H:i:s'), 'user_url' => $this->faker->domainName, 'user_pass' => $this->faker->password));
     if (is_wp_error($ID)) {
         return;
     }
     if (\WP_CLI\Utils\get_flag_value($args, 'billing', false)) {
         $billing = array('first-name' => $first, 'last-name' => $last, 'company-name' => $this->faker->company, 'address1' => $this->faker->streetAddress, 'address2' => rand(0, 1) ? $this->faker->secondaryAddress : '', 'city' => $this->faker->city, 'state' => $this->faker->stateAbbr, 'zip' => $this->faker->postcode, 'country' => 'US', 'email' => $this->faker->companyEmail, 'phone' => $this->faker->phoneNumber);
         update_user_meta($ID, 'it-exchange-billing-address', $billing);
     }
 }
开发者ID:pemiu01,项目名称:exchange-addon-licensing,代码行数:23,代码来源:ITELIC.php

示例3: setUser

 private function setUser($username = '', $password = '', $email = '', $supperAdmin = false)
 {
     $passwordEncoder = $this->container->get('security.password_encoder');
     $user = new User();
     $user->setUsername($username ?: $this->faker->name);
     $user->setUsernameCanonical($username ?: $user->getUsername());
     $user->setEmail($email ?: $this->faker->email);
     $user->setEmailCanonical($email ?: $user->getEmail());
     $user->setEnabled($supperAdmin ? true : (bool) mt_rand(0, 1));
     $user->setSuperAdmin((bool) $supperAdmin);
     $encodedPassword = $passwordEncoder->encodePassword($user, $password ?: $user->getUsername());
     $user->setPassword($encodedPassword);
     $user->setCreatedAt($this->faker->dateTimeBetween('-1 year', '-10 days'));
     return $user;
 }
开发者ID:heavenwoo,项目名称:blog,代码行数:15,代码来源:LoadData.php

示例4: othersAttributesArray

 /**
  * @param null $uuid
  * @param int  $createbyId
  * @param int  $lastUpdateById
  *
  * @return array
  */
 public function othersAttributesArray($uuid = null, $createbyId = 1, $lastUpdateById = 1)
 {
     if (null == $uuid) {
         $uuid = $this->fake->uuid;
     }
     return array('uuid' => $uuid, 'createby_id' => $createbyId, 'lastupdateby_id' => $lastUpdateById, 'created_at' => $this->fake->dateTimeBetween(), 'updated_at' => $this->fake->dateTimeBetween());
 }
开发者ID:emayk,项目名称:ics,代码行数:14,代码来源:AbstractGenerate.php

示例5: generate

 /**
  * Generate renewal records.
  *
  * ## Options
  *
  * <rate>
  * : Renewal rate as a percentage. Ex: 50 or 35
  *
  * [--product=<product>]
  * : Only generate renewals for a certain product.
  *
  * @param $args
  * @param $assoc_args
  */
 public function generate($args, $assoc_args)
 {
     list($rate) = $args;
     if ($rate < 1 || $rate > 100) {
         WP_CLI::error("Usage: 1 < <rate> <= 100");
     }
     $query_args = array('status' => \ITELIC\Key::EXPIRED);
     if ($p = \WP_CLI\Utils\get_flag_value($assoc_args, 'product')) {
         $query_args['product'] = $p;
     }
     $keys = itelic_get_keys($query_args);
     $notify = \WP_CLI\Utils\make_progress_bar('Generating renewals.', count($keys));
     foreach ($keys as $key) {
         if (rand(0, 100) <= $rate) {
             $min = $key->get_expires();
             $min->sub(new DateInterval('P15D'));
             $max = $key->get_expires();
             $max->add(new DateInterval('P30D'));
             $txn = itelic_create_renewal_transaction(array('key' => $key->get_key(), 'date' => $this->faker->dateTimeBetween($min, $max)->format('Y-m-d H:i:s')));
             if (is_wp_error($txn)) {
                 WP_CLI::error($txn);
             }
             $key->renew($txn);
         }
         $notify->tick();
     }
     $notify->finish();
 }
开发者ID:pemiu01,项目名称:exchange-addon-licensing,代码行数:42,代码来源:Renewal.php

示例6: load

 public function load(ObjectManager $manager)
 {
     $user = $manager->getRepository('TaichiUserBundle:User')->findOneBy(['username' => 'heaven']);
     foreach (range(1, self::POST_NUMS) as $i) {
         $post = new Post();
         $categories = $manager->getRepository('TaichiBlogBundle:Category')->findAll();
         $categoryIds = [];
         foreach ($categories as $category) {
             $categoryIds[] = $category->getId();
         }
         $cIdKey = array_rand($categoryIds, 1);
         $category = $manager->getRepository('TaichiBlogBundle:Category')->find($categoryIds[$cIdKey]);
         $post->setSubject(implode(' ', array_map('ucfirst', $this->faker->words(mt_rand(3, 5)))));
         $post->setAbstract($this->faker->paragraph(mt_rand(2, 4)));
         $post->setContent($this->faker->paragraph(mt_rand(6, 10)));
         $post->setUser($user);
         $post->setCategory($category);
         //Add tags
         $tags = $manager->getRepository('TaichiBlogBundle:Tag')->findAll();
         $tagIds = [];
         foreach ($tags as $tag) {
             $tagIds[] = $tag->getId();
         }
         $tIdKeys = array_rand($tagIds, mt_rand(2, 5));
         foreach ($tIdKeys as $tIdKey) {
             $tag = $manager->getRepository('TaichiBlogBundle:Tag')->find($tagIds[$tIdKey]);
             $post->addTag($tag);
         }
         $post->setPictureUrl($this->faker->imageUrl(400, 240));
         $post->setCreatedAt($this->faker->dateTimeBetween('-1 year', '-10 days'));
         $post->setUpdatedAt($post->getCreatedAt());
         foreach (range(1, mt_rand(1, self::COMMENT_NUMS)) as $j) {
             $comment = new Comment();
             $comment->setUser($user);
             $comment->setCreatedAt($this->faker->dateTimeBetween($post->getCreatedAt(), 'now'));
             $comment->setUpdatedAt($comment->getCreatedAt());
             $comment->setContent($this->faker->paragraph(mt_rand(1, 3)));
             $comment->setPost($post);
             $manager->persist($comment);
             $post->addComment($comment);
         }
         $manager->persist($post);
     }
     $manager->flush();
 }
开发者ID:heavenwoo,项目名称:blog,代码行数:45,代码来源:LoadPostsData.php

示例7: testPersonalIdentityNumberGeneratesCompliantNumbers

 public function testPersonalIdentityNumberGeneratesCompliantNumbers()
 {
     for ($i = 0; $i < 10; $i++) {
         $birthdate = $this->faker->dateTimeBetween('1800-01-01 00:00:00', '1899-12-31 23:59:59');
         $pin = $this->faker->personalIdentityNumber($birthdate);
         $this->assertRegExp('/^[0-9]{6}\\+[0-9]{3}[0-9ABCDEFHJKLMNPRSTUVWXY]$/', $pin);
     }
     for ($i = 0; $i < 10; $i++) {
         $birthdate = $this->faker->dateTimeBetween('1900-01-01 00:00:00', '1999-12-31 23:59:59');
         $pin = $this->faker->personalIdentityNumber($birthdate);
         $this->assertRegExp('/^[0-9]{6}-[0-9]{3}[0-9ABCDEFHJKLMNPRSTUVWXY]$/', $pin);
     }
     for ($i = 0; $i < 10; $i++) {
         $birthdate = $this->faker->dateTimeBetween('2000-01-01 00:00:00', '2099-12-31 23:59:59');
         $pin = $this->faker->personalIdentityNumber($birthdate);
         $this->assertRegExp('/^[0-9]{6}A[0-9]{3}[0-9ABCDEFHJKLMNPRSTUVWXY]$/', $pin);
     }
 }
开发者ID:Newman101,项目名称:Faker,代码行数:18,代码来源:PersonTest.php

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

示例9: create

 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var ProductInterface $product */
     $product = $this->productFactory->createNew();
     $product->setVariantSelectionMethod(ProductInterface::VARIANT_SELECTION_MATCH);
     $product->setCode($options['code']);
     $product->setEnabled($options['enabled']);
     $product->setMainTaxon($options['main_taxon']);
     $product->setCreatedAt($this->faker->dateTimeBetween('-1 week', 'now'));
     foreach ($this->getLocales() as $localeCode) {
         $product->setCurrentLocale($localeCode);
         $product->setFallbackLocale($localeCode);
         $product->setName($options['name']);
         $product->setShortDescription($options['short_description']);
         $product->setDescription($options['description']);
     }
     foreach ($options['taxons'] as $taxon) {
         $product->addTaxon($taxon);
     }
     foreach ($options['channels'] as $channel) {
         $product->addChannel($channel);
     }
     foreach ($options['product_options'] as $option) {
         $product->addOption($option);
     }
     foreach ($options['product_attributes'] as $attribute) {
         $product->addAttribute($attribute);
     }
     try {
         $this->variantGenerator->generate($product);
     } catch (\InvalidArgumentException $exception) {
         /** @var ProductVariantInterface $productVariant */
         $productVariant = $this->productVariantFactory->createNew();
         $product->addVariant($productVariant);
     }
     $i = 0;
     /** @var ProductVariantInterface $productVariant */
     foreach ($product->getVariants() as $productVariant) {
         $productVariant->setAvailableOn($this->faker->dateTimeThisYear);
         $productVariant->setPrice($this->faker->randomNumber(4));
         $productVariant->setCode(sprintf('%s-variant#%d', $options['code'], $i));
         $productVariant->setOnHand($this->faker->randomNumber(1));
         ++$i;
     }
     foreach ($options['images'] as $imageCode => $imagePath) {
         /** @var ImageInterface $productImage */
         $productImage = $this->productImageFactory->createNew();
         $productImage->setCode($imageCode);
         $productImage->setFile(new UploadedFile($imagePath, basename($imagePath)));
         $this->imageUploader->upload($productImage);
         $product->addImage($productImage);
     }
     return $product;
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:58,代码来源:ProductExampleFactory.php

示例10: create

 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var ProductInterface $product */
     $product = $this->productFactory->createNew();
     $product->setVariantSelectionMethod(ProductInterface::VARIANT_SELECTION_MATCH);
     $product->setCode($options['code']);
     $product->setEnabled($options['enabled']);
     $product->setMainTaxon($options['main_taxon']);
     $product->setCreatedAt($this->faker->dateTimeBetween('-1 week', 'now'));
     $this->createTranslations($product, $options);
     $this->createRelations($product, $options);
     $this->createVariants($product, $options);
     $this->createImages($product, $options);
     return $product;
 }
开发者ID:loic425,项目名称:Sylius,代码行数:19,代码来源:ProductExampleFactory.php

示例11: create_activations_for_key

 /**
  * Create activation records for a license key.
  *
  * @param \ITELIC\Key $key
  */
 protected function create_activations_for_key(ITELIC\Key $key)
 {
     if (in_array($key->get_status(), array(\ITELIC\Key::EXPIRED, \ITELIC\Key::DISABLED))) {
         return;
     }
     $limit = $key->get_max();
     if (empty($limit)) {
         $limit = 20;
     }
     $limit = min($limit, $limit / 2 + 2);
     $created = $key->get_transaction()->post_date_gmt;
     $end = \ITELIC\make_date_time($created);
     $end->add(new DateInterval('P5D'));
     $creation_date = $this->faker->dateTimeBetween($created, $end);
     $release = $this->get_release_for_date($key, $creation_date);
     if (!$release) {
         WP_CLI::error("Release not created.");
     }
     \ITELIC\Activation::create($key, $this->faker->domainName, $creation_date, $release);
     $count = rand(0, $limit - 1);
     if (!$count) {
         return;
     }
     $now = new DateTime();
     for ($i = 0; $i < $count; $i++) {
         $expires = $key->get_expires();
         if ($expires > $now) {
             $max = $now;
         } else {
             $max = $expires;
         }
         $creation_date = $this->faker->dateTimeBetween($created, $max);
         $release = $this->get_release_for_date($key, $creation_date);
         try {
             $a = \ITELIC\Activation::create($key, $this->faker->domainName, $creation_date, $release);
         } catch (LogicException $e) {
             continue;
         } catch (IronBound\DB\Exception $e) {
             continue;
         }
         if (!rand(0, 3)) {
             $deactivate_date = $this->faker->dateTimeBetween($creation_date, $max);
             $a->deactivate($deactivate_date);
         }
     }
 }
开发者ID:pemiu01,项目名称:exchange-addon-licensing,代码行数:51,代码来源:Key.php

示例12: seedGuardian

 private function seedGuardian()
 {
     $shirtSizes = ['S', 'YS', 'M', 'L', 'YL', 'YM'];
     $addresses = ['Home', 'Work', 'Church', 'Vacation Home'];
     $savedAddresses = [];
     foreach ($addresses as $key => $name) {
         $savedAddresses[] = factory(Address::class)->create(['name' => $name]);
     }
     self::$guardian = User::create(['status' => User::STATUS_CONFIRMED, 'first_name' => 'Ben', 'last_name' => 'Guardian', 'email' => self::GUARDIAN_EMAIL, 'phone' => '5553546789', 'password' => bcrypt('changeme'), 'primary_address_id' => $savedAddresses[0]->id]);
     self::$guardian->addresses()->saveMany($savedAddresses);
     // Generate fake player information.
     $playerCreator = App::make(PlayerCreator::class);
     $playerCreator->create(self::$guardian, ['first_name' => 'David', 'last_name' => 'Webb', 'gender' => 'M', 'birthday' => $this->faker->dateTimeBetween('-18 years', '-9 years')->format('m/d/Y')]);
     self::$guardian = User::findOrFail(self::$guardian->id);
     $playerCreator->create(self::$guardian, ['first_name' => 'Ethan', 'last_name' => 'Smith', 'gender' => 'M', 'birthday' => $this->faker->dateTimeBetween('-18 years', '-9 years')->format('m/d/Y')]);
     $playerCreator->create(self::$guardian, ['first_name' => 'Olivia', 'last_name' => 'Brown', 'gender' => 'F', 'birthday' => $this->faker->dateTimeBetween('-18 years', '-9 years')->format('m/d/Y')]);
     $playerCreator->create(self::$guardian, ['first_name' => 'Brad', 'last_name' => 'Anderson', 'gender' => 'M', 'birthday' => $this->faker->dateTimeBetween('-18 years', '-9 years')->format('m/d/Y')]);
 }
开发者ID:BibleBowl,项目名称:account,代码行数:18,代码来源:DatabaseSeeder.php

示例13: generateDateData

 /**
  * Generate a date product value data
  *
  * @param AbstractAttribute attribute
  *
  * @return string
  */
 protected function generateDateData(AbstractAttribute $attribute)
 {
     $date = $this->faker->dateTimeBetween($attribute->getDateMin(), $attribute->getDateMax());
     return $date->format('Y-m-d');
 }
开发者ID:norfil,项目名称:DataGeneratorBundle,代码行数:12,代码来源:ProductGenerator.php

示例14: randomDate

 private function randomDate()
 {
     return $this->faker->dateTimeBetween('-5 days');
 }
开发者ID:scandesignsdk,项目名称:scangammon,代码行数:4,代码来源:LoadGames.php

示例15: getDummyData

 public function getDummyData(Generator $faker, array $customValues = array())
 {
     return ['fecha_inicio' => $faker->dateTimeBetween($startDate = '-1 years', $endDate = 'now'), 'cliente_id' => $this->getRandom('Cliente')->id, 'tipo' => $faker->randomElement(['Local', 'Local', 'Nacional']), 'tiempo' => $faker->randomElement(['24 horas', '48 horas', '2 dias']), 'nro_orden' => $faker->randomNumber(6), 'estado' => $faker->randomElement(['En proceso', 'Despachado'])];
 }
开发者ID:jkrlos2791,项目名称:Courier,代码行数:4,代码来源:OrdenServicioTableSeeder.php


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