From 38a80dc6468c7e7cfaa4e22d4e4b8e3b374cf388 Mon Sep 17 00:00:00 2001 From: piernov Date: Sun, 24 Apr 2016 22:06:40 +0200 Subject: Add PHP Inventory class --- inc/Inventory.inc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 inc/Inventory.inc (limited to 'inc/Inventory.inc') diff --git a/inc/Inventory.inc b/inc/Inventory.inc new file mode 100644 index 0000000..efe54f2 --- /dev/null +++ b/inc/Inventory.inc @@ -0,0 +1,41 @@ +items; + } + + public static function get() { + if(!self::created()) { + $_SESSION["inventory"] = new Inventory(); + } + return $_SESSION["inventory"]; + } + + private function _addItem($item) { + $this->items[] = $item; + } + + public static function addItem($item) { + $inv = self::get(); + $inv->_addItem($item); + } + + private function _removeItem($item) { + unset($this->items[array_search($item, $this->items)]); + } + + public static function removeItem($item) { + $inv = self::get(); + $inv->_removeItem($item); + } +} + +?> -- cgit v1.2.3-70-g09d2