PHP code example of jojo1981 / typed-set

1. Go to this page and download the library: Download jojo1981/typed-set 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/ */

    

jojo1981 / typed-set example snippets




me examples on how to construct a set

$set1 = new \Jojo1981\TypedSet\Set('string', ['text1', 'text2', 'text1']);
$set1->count(); // will return 2
$set1->contains('text1'); // will return true
$set1->contains('text3'); // will return false

$set2 = \Jojo1981\TypedSet\Set::createFromElements([1, 6, 7, 1, 2, 2, 9]);
$set2->count(); // will return 5
$set2->add(7);
$set2->count(); // will return 5
$set2->add(8);
$set2->count(); // will return 6

$set3 = new \Jojo1981\TypedSet\Set(\Jojo1981\TypedSet\TestSuite\Fixture\InterfaceTestEntity::class);
$set3->addAll([new \Jojo1981\TypedSet\TestSuite\Fixture\TestEntity(), new \Jojo1981\TypedSet\TestSuite\Fixture\TestEntityBase()]);
$set1->count(); // will return 2



tionally you can enable the default handlers before or after registering your own handlers.
\Jojo1981\TypedSet\Handler\GlobalHandler::getInstance()->addDefaultHandlers();

// Register a custom handler
\Jojo1981\TypedSet\Handler\GlobalHandler::getInstance()->registerHandler(new \Jojo1981\TypedSet\TestSuite\Fixture\PersonHandler());