Skip to content

p810/tuple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tuple

An implementation of tuples in PHP.

Installation

composer require p810/tuple --no-dev

Usage

<?php

use function p810\Tuple\tuple;

$tuple = tuple('foo', 'bar');

You can also use the Tag Space Unicode character (U+E0020) as a function to make it look like tuples do in Python. This is a proof of concept that I thought would be fun to add. Your coworkers probably won't think it's very fun though so please, weigh your options before using this.

$tuple = 󠀠('hello', 'world');
var_dump($tuple); // => p810\Tuple\Tuple#3 (2) {...}

Why?

This is a project I wanted to take on just because. I borrowed the idea from Python, which was my first introduction to the concept.

All in all, this utility is just a wrapper around a PHP object that implements ArrayAccess and restricts the ability to update, set, or remove items, which makes it immutable.

About

An implementation of tuples in PHP.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages