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


PHP Generator::boolean方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     $this->faker = Factory::create();
     $this->id = TwitterMessageId::create($this->faker->uuid);
     $this->lang = $this->faker->countryISOAlpha3;
     $this->userName = $this->faker->userName;
     $this->hashtagText = $this->faker->word;
     $this->text = $this->faker->text();
     $this->complexText = '@' . $this->userName . ' ' . $this->text . ' #' . $this->hashtagText;
     $this->date = new \DateTimeImmutable();
     $this->coordinates = \Mockery::mock(TwitterCoordinates::class);
     $this->place = \Mockery::mock(TwitterPlace::class);
     $this->inReplyToStatusId = $this->faker->randomNumber();
     $this->inReplyToUserId = $this->faker->randomNumber();
     $this->inReplyToScreenName = $this->faker->userName;
     $this->retweeted = $this->faker->boolean();
     $this->retweetCount = $this->faker->randomNumber();
     $this->favorited = $this->faker->boolean();
     $this->favoriteCount = $this->faker->randomNumber();
     $this->truncated = $this->faker->boolean();
     $this->source = null;
     $this->retweetedStatus = \Mockery::mock(Tweet::class);
     $this->hashtag = \Mockery::mock(TwitterHashtag::class);
     $this->userMention = \Mockery::mock(TwitterUserMention::class);
     $this->sender = \Mockery::mock(TwitterUser::class);
     $this->recipient = \Mockery::mock(TwitterUser::class);
     $this->entities = \Mockery::mock(TwitterEntities::class);
 }
开发者ID:remi-san,项目名称:twitter,代码行数:28,代码来源:TweetTest.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $shops = $this->shopRepository->findAll();
     // assign 3 shipping plans with 3 shipping optinos each to 80% of shops
     foreach ($shops as $shop) {
         if ($this->faker->boolean(20)) {
             continue;
         }
         /** @var Shop $shop */
         $shop->shippingPlans()->saveMany(factory(ShippingPlan::class, 3)->make())->each(function ($shippingPlan) {
             /** @var ShippingPlan $shippingPlan */
             $shippingPlan->shippingOptions()->saveMany(factory(ShippingOption::class, 3)->make());
         });
     }
     // assign shipping plan to each product if owner has any
     // or 0 if owner doesn't
     $products = $this->productRepository->with('owner.shippingPlans')->findAll();
     foreach ($products as $product) {
         /** @var Seller $seller */
         $seller = $product->seller;
         if ($seller->shippingPlans->count()) {
             /** @var Product $product */
             $product->shippingPlans()->attach($seller->shippingPlans->random()->id);
         }
     }
 }
开发者ID:gez-studio,项目名称:gez-mall,代码行数:31,代码来源:ShippingPlanSeeder.php

示例3: __construct

 /**
  * @param FactoryInterface $userFactory
  */
 public function __construct(FactoryInterface $userFactory)
 {
     $this->userFactory = $userFactory;
     $this->faker = \Faker\Factory::create();
     $this->optionsResolver = (new OptionsResolver())->setDefault('email', function (Options $options) {
         return $this->faker->email;
     })->setDefault('username', function (Options $options) {
         return $this->faker->firstName . ' ' . $this->faker->lastName;
     })->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('enabled', 'bool')->setDefault('password', 'password123')->setDefault('api', false);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:15,代码来源:AdminUserExampleFactory.php

示例4: randomWinType

 /**
  * @return int
  */
 private function randomWinType()
 {
     $normal = $this->faker->boolean(70);
     if ($normal) {
         return Game::WINTYPE_NORMAL;
     }
     $backgammon = $this->faker->boolean(10);
     if ($backgammon) {
         return Game::WINTYPE_BACKGAMMON;
     }
     return Game::WINTYPE_GAMMON;
 }
开发者ID:scandesignsdk,项目名称:scangammon,代码行数:15,代码来源:LoadGames.php

示例5: __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

示例6: __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

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

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

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $shops = $this->shopRepository->findAll();
     foreach ($shops as $shop) {
         if ($this->faker->boolean(80)) {
             $this->seed($shop);
         }
     }
     $users = $this->userRepository->findAll();
     foreach ($users as $user) {
         if ($this->faker->boolean(80)) {
             $this->seed($user);
         }
     }
 }
开发者ID:gez-studio,项目名称:gez-mall,代码行数:20,代码来源:PaymentMethodSeeder.php

示例10: completeCheckout

 /**
  * @param OrderInterface $order
  */
 private function completeCheckout(OrderInterface $order)
 {
     if ($this->faker->boolean(25)) {
         $order->setNotes($this->faker->sentence);
     }
     $this->applyCheckoutStateTransition($order, OrderCheckoutTransitions::TRANSITION_COMPLETE);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:10,代码来源:OrderFixture.php

示例11: __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

示例12: __construct

 /**
  * @param FactoryInterface $productFactory
  * @param FactoryInterface $productVariantFactory
  * @param ProductVariantGeneratorInterface $variantGenerator
  * @param FactoryInterface $productAttributeValueFactory
  * @param FactoryInterface $productImageFactory
  * @param ImageUploaderInterface $imageUploader
  * @param SlugGeneratorInterface $slugGenerator
  * @param RepositoryInterface $taxonRepository
  * @param RepositoryInterface $productAttributeRepository
  * @param RepositoryInterface $productOptionRepository
  * @param RepositoryInterface $channelRepository
  * @param RepositoryInterface $localeRepository
  */
 public function __construct(FactoryInterface $productFactory, FactoryInterface $productVariantFactory, ProductVariantGeneratorInterface $variantGenerator, FactoryInterface $productAttributeValueFactory, FactoryInterface $productImageFactory, ImageUploaderInterface $imageUploader, SlugGeneratorInterface $slugGenerator, RepositoryInterface $taxonRepository, RepositoryInterface $productAttributeRepository, RepositoryInterface $productOptionRepository, RepositoryInterface $channelRepository, RepositoryInterface $localeRepository)
 {
     $this->productFactory = $productFactory;
     $this->productVariantFactory = $productVariantFactory;
     $this->variantGenerator = $variantGenerator;
     $this->productImageFactory = $productImageFactory;
     $this->imageUploader = $imageUploader;
     $this->slugGenerator = $slugGenerator;
     $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('short_description', function (Options $options) {
         return $this->faker->paragraph;
     })->setDefault('description', function (Options $options) {
         return $this->faker->paragraphs(3, true);
     })->setDefault('main_taxon', LazyOption::randomOne($taxonRepository))->setAllowedTypes('main_taxon', ['null', 'string', TaxonInterface::class])->setNormalizer('main_taxon', LazyOption::findOneBy($taxonRepository, 'code'))->setDefault('taxons', LazyOption::randomOnes($taxonRepository, 3))->setAllowedTypes('taxons', 'array')->setNormalizer('taxons', LazyOption::findBy($taxonRepository, 'code'))->setDefault('channels', LazyOption::randomOnes($channelRepository, 3))->setAllowedTypes('channels', 'array')->setNormalizer('channels', LazyOption::findBy($channelRepository, 'code'))->setDefault('product_attributes', [])->setAllowedTypes('product_attributes', 'array')->setNormalizer('product_attributes', function (Options $options, array $productAttributes) use($productAttributeRepository, $productAttributeValueFactory) {
         $productAttributesValues = [];
         foreach ($productAttributes as $code => $value) {
             /** @var ProductAttributeInterface $productAttribute */
             $productAttribute = $productAttributeRepository->findOneBy(['code' => $code]);
             Assert::notNull($productAttribute);
             /** @var ProductAttributeValueInterface $productAttributeValue */
             $productAttributeValue = $productAttributeValueFactory->createNew();
             $productAttributeValue->setAttribute($productAttribute);
             $productAttributeValue->setValue($value ?: $this->getRandomValueForProductAttribute($productAttribute));
             $productAttributesValues[] = $productAttributeValue;
         }
         return $productAttributesValues;
     })->setDefault('product_options', [])->setAllowedTypes('product_options', 'array')->setNormalizer('product_options', LazyOption::findBy($productOptionRepository, 'code'))->setDefault('images', [])->setAllowedTypes('images', 'array');
 }
开发者ID:loic425,项目名称:Sylius,代码行数:49,代码来源:ProductExampleFactory.php

示例13: generate

 public function generate($databaseName, $size, $batchSize = 1000)
 {
     $this->getConnection()->query(sprintf('USE %s', $databaseName));
     $this->reset();
     $scopes = array_keys($this->scopeFaker);
     $numberOfScopes = count($scopes);
     $currentBatch = 0;
     $createdRecords = 0;
     while ($size > $createdRecords) {
         if ($currentBatch >= $batchSize) {
             $this->flush();
             $currentBatch = 0;
         }
         $createdRecords++;
         $currentBatch++;
         $code = $this->faker->uuid;
         $this->batch['entity'][$code] = ['code' => $code];
         $this->generateAttributes($this->faker, $this->attribute->getAll(), $code, 0);
         if ($this->faker->boolean(66)) {
             $currentScopes = $this->faker->randomElements($scopes, $this->faker->numberBetween(1, $numberOfScopes));
             foreach ($currentScopes as $scopeCode) {
                 $this->generateAttributes($this->scopeFaker[$scopeCode], $this->attribute->getAllScopeAware(), $code, $this->scope->getId($scopeCode));
             }
         }
     }
     if ($currentBatch > 0) {
         $this->flush();
     }
     return $this;
 }
开发者ID:EcomDev,项目名称:mysql-performance-benchmark,代码行数:30,代码来源:Generator.php

示例14: shouldHandle

 /**
  * If we should generate data for a non-required field
  *
  * @param bool $required
  * @return bool
  */
 private function shouldHandle($required)
 {
     if (!$required) {
         $required = $this->generator->boolean($this->config->getChanceRequired());
     }
     return $required;
 }
开发者ID:tebru,项目名称:swagger-faker,代码行数:13,代码来源:SchemaGenerator.php

示例15: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Role::create(['name' => 'owner']);
     $users = $this->userRepository->findAll();
     foreach ($users as $user) {
         if ($this->faker->boolean(50)) {
             $this->seed($user);
         }
     }
     foreach (getTestAccounts() as $testAccount) {
         /** @var User $testUser */
         $testUser = $this->userRepository->findBy('email', $testAccount['email']);
         if (!$testUser->isShopOwner()) {
             $this->seed($testUser);
         }
     }
 }
开发者ID:gez-studio,项目名称:gez-mall,代码行数:22,代码来源:ShopSeeder.php


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