Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. <?php
  2.  
  3. class ArrayAccess implements ArrayAccess {
  4. protected $container = [];
  5.  
  6. public function __construct() {
  7. $this->container = array(
  8. "one" => 1,
  9. "two" => 2,
  10. "three" => 3,
  11. );
  12. }
  13.  
  14. public function offsetSet($offset, $value) {
  15. if (is_null($offset)) {
  16. $this->container[] = $value;
  17. } else {
  18. $this->container[$offset] = $value;
  19. }
  20. }
  21.  
  22. public function offsetExists($offset) {
  23. return isset($this->container[$offset]);
  24. }
  25.  
  26. public function offsetUnset($offset) {
  27. unset($this->container[$offset]);
  28. }
  29.  
  30. public function offsetGet($offset) {
  31. return isset($this->container[$offset]) ? $this->container[$offset] : null;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement