- random_int: documentation ( source)
<?php
class Product {
private string $title;
private string $description;
private int $price;
private string $currency;
private string $category;
private string $brand;
private array $options;
/**
* @return string
*/
public function getTitle(): string
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle(string $title): void
{
$this->title = $title;
}
/**
* @return string
*/
public function getDescription(): string
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription(string $description): void
{
$this->description = $description;
}
/**
* @return int
*/
public function getPrice(): int
{
return $this->price;
}
/**
* @param int $price
*/
public function setPrice(int $price): void
{
$this->price = $price;
}
/**
* @return string
*/
public function getCurrency(): string
{
return $this->currency;
}
/**
* @param string $currency
*/
public function setCurrency(string $currency): void
{
$this->currency = $currency;
}
/**
* @return string
*/
public function getCategory(): string
{
return $this->category;
}
/**
* @param string $category
*/
public function setCategory(string $category): void
{
$this->category = $category;
}
/**
* @return string
*/
public function getBrand(): string
{
return $this->brand;
}
/**
* @param string $brand
*/
public function setBrand(string $brand): void
{
$this->brand = $brand;
}
/**
* @return array
*/
public function getOptions(): array
{
return $this->options;
}
/**
* @param array $options
*/
public function setOptions(array $options): void
{
$this->options = $options;
}
}
class Option {
private string $title;
private string $description;
private int $price;
private array $items;
/**
* @param string $title
*/
public function setTitle(string $title): void
{
$this->title = $title;
}
/**
* @param string $description
*/
public function setDescription(string $description): void
{
$this->description = $description;
}
/**
* @param int $price
*/
public function setPrice(int $price): void
{
$this->price = $price;
}
/**
* @param array $items
*/
public function setItems(array $items): void
{
$this->items = $items;
}
}
class OptionItem {
private string $title;
private string $description;
private int $price;
/**
* @param string $title
*/
public function setTitle(string $title): void
{
$this->title = $title;
}
/**
* @param string $description
*/
public function setDescription(string $description): void
{
$this->description = $description;
}
/**
* @param int $price
*/
public function setPrice(int $price): void
{
$this->price = $price;
}
}
$products = [];
for ($k = 0; $k <= 100; $k++) {
$product = new Product();
$product->setTitle('Product' . $k);
$product->setDescription('Product ' . $k . ' Description');
$product->setPrice(random_int(1000, 10000));
$product->setCurrency('USD');
$product->setCategory('Category' . $k);
$product->setBrand('Brand' . $k);
$options = [];
for ($j = 0; $j <= 10; $j++) {
$option = new Option();
$option->setTitle('Option' . $j);
$option->setDescription('Option ' . $j . ' Description');
$option->setPrice(random_int(1000, 10000));
$optionItems = [];
for ($i = 0; $i <= 100; $i++) {
$optionItem = new OptionItem();
$optionItem->setTitle('Option Item' . $i);
$optionItem->setDescription('Option Item ' . $i . ' Description');
$optionItem->setPrice(random_int(1000, 10000));
$optionItems[] = $optionItem;
}
$option->setItems($optionItems);
$options[] = $option;
}
$product->setOptions($options);
$products[] = $product;
}