PHP code example of mistralys / application-utils-collections

1. Go to this page and download the library: Download mistralys/application-utils-collections library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mistralys / application-utils-collections example snippets


$basil = Herbs::getInstance()->getByID(Herbs::BASIL);

echo $basil->getID(); // basil
echo $basil->getName(); // Basil

foreach(Herbs::getInstance()->getAll() as $herb) {
    echo $herb->getName();
}

use AppUtils\Baskets\GenericIntegerPrimaryBasket;

$products = GenericIntegerPrimaryBasket::create();

$products->addItem(new Product(289, 'Product A'));
$products->addItem(new Product(290, 'Product B'));

$products->removeItem(290);

use AppUtils\Collections\Events\ItemsInitializedEvent;use AppUtilsTestClasses\StringPrimaryCollectionImpl;

$collection = new StringPrimaryCollectionImpl();

// Register listeners before accessing the items
$collection->onItemsInitialized(function(ItemsInitializedEvent $event) : void {
    // Do something
});

$collection->getAll(); // This, for example, will trigger the event