コード例 #1
0
ファイル: Radio.php プロジェクト: Nycto/Round-Eights
 /**
  * Returns the an HTML tag that represents an individual option's label
  *
  * @param String|Integer $value The value of the option whose label tag should be returned
  * @return \r8\HTML\Tag
  */
 public function getOptionLabelTag($value)
 {
     $value = \r8\indexVal($value);
     if (!$this->hasOption($value)) {
         throw new \r8\Exception\Index($value, "Option Value", "Option does not exist in field");
     }
     return new \r8\HTML\Tag('label', $this->getOptionLabel($value), array("for" => $this->getRadioOptionID($value)));
 }
コード例 #2
0
ファイル: Namespaced.php プロジェクト: Nycto/Round-Eights
 /**
  * Constructor...
  *
  * @param String $namespace The namespace to nest values within
  * @param \r8\iface\Session $decorated The object being decorated
  */
 public function __construct($namespace, \r8\iface\Session $decorated)
 {
     parent::__construct($decorated);
     $namespace = \r8\indexVal($namespace);
     if (\r8\IsEmpty($namespace)) {
         throw new \r8\Exception\Argument(0, "Namespace", "Must be a valid key");
     }
     $this->namespace = $namespace;
 }
コード例 #3
0
ファイル: Value.php プロジェクト: Nycto/Round-Eights
 /**
  * Constructor...
  *
  * @param String $key The key to reference within the session
  * @param \r8\iface\Session $session The session to pull and push values to
  */
 public function __construct($key, \r8\iface\Session $session)
 {
     $key = \r8\indexVal($key);
     if (\r8\IsEmpty($key)) {
         throw new \r8\Exception\Argument(0, "key", "Must be a valid key");
     }
     $this->key = $key;
     $this->session = $session;
 }
コード例 #4
0
ファイル: Local.php プロジェクト: Nycto/Round-Eights
 /**
  * Decrements a given value by one
  *
  * @param String $key The key for the value
  * @return \r8\Cache\Local Returns a self reference
  */
 public function decrement($key)
 {
     $key = \r8\indexVal($key);
     if (!isset($this->cache[$key]) || !\is_numeric($this->cache[$key]['val'])) {
         $this->set($key, 0, 0);
     } else {
         $this->cache[$key]['val']--;
     }
     return $this;
 }
コード例 #5
0
ファイル: Suffix.php プロジェクト: Nycto/Round-Eights
 /**
  * Attaches the prefix to the given key
  *
  * @param String $key
  * @return String
  */
 private function prepareKey($key)
 {
     return \r8\indexVal($key) . $this->suffix;
 }
コード例 #6
0
ファイル: Group.php プロジェクト: Nycto/Round-Eights
 /**
  * Constructor...
  *
  * @param String $field The inner field to group the results by
  * @param \Iterator $iterator The inner iterator being wrapped
  */
 public function __construct($field, \Iterator $inner)
 {
     $this->field = \r8\indexVal($field);
     $this->inner = $inner;
 }
コード例 #7
0
ファイル: array.php プロジェクト: Nycto/Round-Eights
/**
 * Returns the offset of a given key
 *
 * This will throw an exception if the key is not found in the array
 *
 * @param Array $array The array to operate on
 * @param Mixed $key The key to look up
 * @return Integer Returns the offset of the key
 */
function keyOffset(array $array, $key)
{
    $key = \r8\indexVal($key);
    if (!array_key_exists($key, $array)) {
        throw new \r8\Exception\Argument(1, "Key", "Key does not exist");
    }
    return array_search($key, array_keys($array));
}
コード例 #8
0
ファイル: Group.php プロジェクト: Nycto/Round-Eights
 /**
  * Constructor...
  *
  * @param String $group The group name
  * @param \r8\iface\Cache $cache The cache being wrapped
  */
 public function __construct($group, \r8\iface\Cache $cache)
 {
     $this->group = \r8\indexVal($group);
     $this->cache = $cache;
 }
コード例 #9
0
ファイル: Multi.php プロジェクト: Nycto/Round-Eights
 /**
  * Returns the label for an option based on it's value
  *
  * @param mixed $value The option value to look up
  * @return String Returns the label for the given option
  */
 public function getOptionLabel($value)
 {
     $value = \r8\indexVal($value);
     if (!$this->hasOption($value)) {
         throw new \r8\Exception\Index($value, "Option Value", "Option does not exist in field");
     }
     return $this->options[$value];
 }
コード例 #10
0
ファイル: APC.php プロジェクト: Nycto/Round-Eights
 /**
  * Sets a new caching value, but only if that value doesn't exist
  *
  * @param String $key The key for the value
  * @param mixed $value The value to set
  * @param Integer $expire The lifespan of this cache value, in seconds
  * @return \r8\Cache\Memcache Returns a self reference
  */
 public function add($key, $value, $expire = 0)
 {
     \apc_add(\r8\indexVal($key), \serialize($value), max(0, (int) $expire));
     return $this;
 }
コード例 #11
0
ファイル: Value.php プロジェクト: Nycto/Round-Eights
 /**
  * Constructor...
  *
  * @param String $key The key to this value
  * @param \r8\iface\Cache $cache The cache to interact with
  */
 public function __construct($key, \r8\iface\Cache $cache)
 {
     $this->key = \r8\indexVal($key);
     $this->cache = $cache;
 }
コード例 #12
0
ファイル: general.php プロジェクト: Nycto/Round-Eights
 public function testIndexVal()
 {
     $this->assertSame(0, \r8\indexVal(FALSE));
     $this->assertSame(1, \r8\indexVal(TRUE));
     $this->assertSame("", \r8\indexVal(""));
     $this->assertSame(0, \r8\indexVal(0));
     $this->assertSame("", \r8\indexVal(NULL));
     $this->assertSame("", \r8\indexVal(array()));
     $this->assertSame("  ", \r8\indexVal("  "));
     $this->assertSame("string", \r8\indexVal("string"));
     $this->assertSame(1, \r8\indexVal(1));
     $this->assertSame("0", \r8\indexVal("0"));
     $this->assertSame("1", \r8\indexVal("1"));
     $this->assertSame(1, \r8\indexVal(array(1)));
 }