liorchamla/faker-prices

Provides typical and credible prices for Faker (fzaninotto/faker or fakerphp/faker) library

2.0.0 2020-12-29 08:40 UTC

This package is auto-updated.

Last update: 2024-05-29 04:15:54 UTC


README

Providing typical and credible prices for fzaninotto/faker !

Contents

  1. Installation
  2. Basic Usage
  3. Details

Installation

composer require liorchamla/faker-prices

Basic Usage

You just have to add the Prices provider to Faker as any other provider :

<?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

Details

You can use several parameters :

// 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