/** * Returns the precedence level of this clause * * The number this returns is arbitrary, it's only importance is it's value * relative to other where clauses. A higher value means this clause * has a more important order of operation. * * @return Integer */ public function getPrecedence() { if ($this->countClauses() != 1) { return 50; } // If there is only one clause in this instance, then mask the precedence // to reduce the number of parenthesis that are added return \r8\ary\first($this->getClauses())->getPrecedence(); }
/** * Checks and handles errors * * @return NULL */ private function handleErrors() { $result = $this->memcached->getResultCode(); if ($result === \Memcached::RES_SUCCESS || $result === \Memcached::RES_NOTFOUND || $result === \Memcached::RES_NOTSTORED || $result === \Memcached::RES_DATA_EXISTS) { return NULL; } $refl = new \ReflectionClass('\\Memcached'); $constant = \r8\ary\first(preg_grep('/^RES_/', array_keys(array_filter($refl->getConstants(), function ($value) use($result) { return $result == $value; })))); if (empty($constant)) { $constant = "UNKNOWN"; } throw new \r8\Exception\Cache("Memcache Error: " . $constant, $result); }
public function testFirst() { $this->assertNull(\r8\ary\first(array())); $this->assertSame("value", \r8\ary\first(array("value"))); $this->assertSame(1, \r8\ary\first(range(1, 20))); }
/** * Adds a argument that this command will consume * * @param \r8\iface\CLI\Arg $arg * @return \r8\Args\Option Returns a self reference */ public function addArg(\r8\iface\CLI\Arg $arg) { \r8\ary\first($this->forms)->addArg($arg); return $this; }