/** * getItemDataByName * * Attempts to fetch a cached version of the requested * item search. Otherwise, it calls the parent function. * * @return string[] An associative array * @param string $item The name of the item * @param string[] $filter Associative array of search parameters */ public function getItemDataByName($itemName, $filter = NULL) { if ($filter && is_array($filter)) { $this->cacheID = "s" . md5($itemName . implode('', $filter)); } else { $this->cacheID = "s" . md5($itemName); } $cached = $this->cacheFetch($this->cacheID); if (!is_array($cached)) { $cached = parent::getItemDataByName($itemName, $filter); if ($this->cacheID) { $scached = serialize($cached); $this->cacheSave($this->cacheID, $scached); unset($this->cacheID); } return $cached; } else { return $cached; } }
<?php /** * phpArmory5 test case * * A test case to derive a new class object from the phpArmory5 class. * @package phpArmory * @subpackage tests */ // Include the phpArmory class library require_once '../phpArmory.class.php'; $areaName = 'eu'; $itemName = "Glimmering Naaru Sliver"; $sapi_type = substr(php_sapi_name(), 0, 3); // Instantiate the class library if ($armory = new phpArmory5($areaName = $areaName)) { $itemNameData = $armory->getItemDataByName($itemName); if ($sapi_type == 'cli') { var_dump($itemNameData); } else { $string = print_r($itemNameData, 1); $string = str_replace(array(" ", "\n"), array(" ", "<br />\n"), $string); echo "\$item = " . $string; } } else { echo "Failed to create a phpArmory5 instance.\n"; }