/** * Retrieves hash on an object descriptor and its related secret information. * * @param string $object some public object hash is to be used for (e.g. a user's name) * @param string $secret some internal-only information related to that object (e.g. the user's internal ID or similar) * @return string * @throws \InvalidArgumentException on missing/invalid object or secret */ public static function get($object, $secret) { $object = trim(data::asString($object)); $secret = trim(data::asString($secret)); if ($object === '' || $secret === '') { throw new \InvalidArgumentException('missing/invalid hashing data'); } return static::_get($object, $secret, time()); }
/** * Fetches items matching all previous criteria. * * @return array[array] items fetched from datasource */ public function items() { if ($this->_sortBy) { $property = $this->_sortBy[0]; $ascending = $this->_sortBy[1]; uasort($this->_items, function ($left, $right) use($property, $ascending) { if (!is_array($left)) { $left = null; } else { if (!array_key_exists($property, $left)) { $left = null; } else { $left = data::asString($left[$property]); } } if (!is_array($right)) { $right = null; } else { if (!array_key_exists($property, $right)) { $right = null; } else { $right = data::asString($right[$property]); } } if ($left === null && $right === null) { return 0; } if ($right === null) { $result = 1; } else { if ($left === null) { $result = -1; } else { $result = strcasecmp($left, $right); } } return $ascending ? $result : -$result; }); } if ($this->_window['size'] > 0) { return array_slice($this->_items, $this->_window['offset'], $this->_window['size'], true); } return array_slice($this->_items, $this->_window['offset'], null, true); }
/** * Retrieves provided content wrapped in content of current capture buffer. * * @param mixed $strContent content to be wrapped, gets converted to string * internally using data::asString() * @return string */ public function wrap($strContent) { return str_replace(static::middleMarker, data::asString($strContent), $this->_captured); }