Skip to content

Instantly share code, notes, and snippets.

@kajstrom
Last active March 29, 2017 12:27
Show Gist options
  • Save kajstrom/a567b46a716e861d740566bbaea73e65 to your computer and use it in GitHub Desktop.
Save kajstrom/a567b46a716e861d740566bbaea73e65 to your computer and use it in GitHub Desktop.
<?php
$list = new MyListContainingClass();
$list->add("stuff", "more", "yeah", "woo");
$list->remove("more", "yeah");
<?php
class MyListContainingClass {
/** @var string[] */
private $list = [];
//other stuff...
public function add(string ...$items)
{
$this->list = array_merge($this->list, $items);
}
public function remove(string ...$items)
{
$this->list = array_diff($this->list, $items);
}
//other stuff...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment