$item = Item::newInstance(); $item->setName("Shirt"); $item->setPrice(29.99);
$items = array(); for ($i = 0; $i < 10; $i++) { $item = Item::newInstance(); $item->setName("Product " . ($i+1)); $item->setPrice(rand(10, 50)); $items[] = $item; }In this example, an array of 10 new instances of the Item class is created using the newInstance method. The setName and setPrice methods are then called on each instance to set their names and prices. The Item newInstance method is part of the Joomla\CMS\Factory\Factory class, which is part of the Joomla content management system.