1. Go to this page and download the library: Download shahmal1yev/gcollection 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/ */
shahmal1yev / gcollection example snippets
enericCollection\GenericCollection;
use GenericCollection\Types\Primitive\StringType;
class Foo
{
public function __toString(): string
{
return "Foo as string";
}
}
// Create a new collection with Foo validation
$collection = new GenericCollection(Foo::class);
// Add items to the collection
$collection[] = new Foo;
$collection->add(1, new Foo);
// Retrieve items from the collection
echo $collection[0];
echo $collection->get(1); // Outputs: Foo as string
// Validate an item
var_dump($collection->validate(new Foo)); // Outputs: bool(true)
enericCollection\GenericCollection;
use GenericCollection\Types\Primitive\StringType;
// Create a new collection with StringType validation
$collection = new GenericCollection(new StringType());
// Add items to the collection
$collection[] = "Hello";
$collection->add(1, "World");
// Retrieve items from the collection
echo $collection[1];
echo $collection->get(0); // Outputs: Hello
// Validate an item
var_dump($collection->validate("Test")); // Outputs: bool(true)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.