liorchamla / faker-prices
为 Faker (fzaninotto/faker 或 fakerphp/faker) 库提供典型和可信的价格
2.0.0
2020-12-29 08:40 UTC
Requires (Dev)
- fakerphp/faker: ^1.13
- pestphp/pest: ^0.3.19
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-09-29 05:20:54 UTC
README
为 fzaninotto/faker 提供!
内容
安装
composer require liorchamla/faker-prices
基本用法
只需将 Prices 提供者添加到 Faker,就像添加其他提供者一样
<?php // Adding the provider to Faker $faker = \Faker\Factory::create(); $faker->addProvider(new Liior\Faker\Prices($faker)); // Using the provider : echo $faker->price(); // prints 49.99
详情
你可以使用多个参数
// Function signature : $faker->price($min = 1000, $max = 20000, $psychologicalPrice = true, $decimals = true) // You can cancel the $psychologicalPrice (which gives you credible prices like 29.49 or 119.99 instead of random 23.49 or 102.49) $faker->price(100, 200, false); // 113.49 $faker->price(100, 200, true); // 109.49 // You can cancel the $decimals also (decimals can be X.29, X.49 or X.99) $faker->price(100, 200, true, false); // 109 $faker->price(100, 200, true, true); // 109.49