PHP code example of simondeeley / tuple

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

    

simondeeley / tuple example snippets


use simondeeley\Tuple;

class MyTuple extends Tuple
{
    //...
}

use simondeeley\Tuple;

class Pair extends Tuple
{
    const MAX_LENGTH = 2;
}

$numeric = new Pair(1, 2);
$strings = new Pair('A', 'B');
$mixed = new Pair(1024, 'FooBar');
$objects = new Pair($numeric, $strings);

use simondeeley\Tuples\Single;
use simondeeley\Tuples\Pair;

$single = new Single('foo'); // Can only ever have one argument
$pair = new Pair(10, 20); // Can only ever have exactly two arguments

$foo = new Pair(1, 2);
$bar = new Pair(1, 2);
$baz = new Pair(2, 1);

$foo->equals($bar); // Returns true
$foo->equals($baz); // Returns false