Last active
March 29, 2017 12:27
-
-
Save kajstrom/a567b46a716e861d740566bbaea73e65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$list = new MyListContainingClass(); | |
$list->add("stuff", "more", "yeah", "woo"); | |
$list->remove("more", "yeah"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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