public function is_authorized($user, $setting) { if (is_boolean($this->authorized[$user][$setting])) { return $this->authorized[$user][$setting]; } return FALSE; }
public function __construct() { if (0 === func_num_args()) { return; } $values = func_get_arg(0); if (!isset($values['value'])) { throw new InvalidTypeException('DoctrineListener', 'value', 'array or string', null); } $this->events = (array) $values['value']; if (isset($values['connection'])) { if (!is_string($values['connection'])) { throw new InvalidTypeException('DoctrineListener', 'connection', 'string', $values['connection']); } $this->connection = $values['connection']; } if (isset($values['lazy'])) { if (!is_boolean($values['lazy'])) { throw new InvalidTypeException('DoctrineListener', 'lazy', 'boolean', $values['lazy']); } $this->lazy = $values['lazy']; } if (isset($values['priority'])) { if (!is_integer($values['priority'])) { throw new InvalidTypeException('DoctrineListener', 'priority', 'integer', $values['priority']); } $this->priority = $values['priority']; } }
/** * autoActiveClass. * * @param bool */ public function autoActiveClass($value) { if (is_boolean($value)) { $this->autoActive = $value; } return $this; }
public function loaded($loaded = null) { if (is_boolean($loaded)) { $this->loaded = $loaded; return $this; } elseif ($this->loaded === null) { $this->loaded = isset($this->values[$this->pk]); return $this->loaded; } else { return $this->loaded; } }
function t_edit($c) { global $info; // create default value for new entries $s = ''; foreach ($info as $i) { $n = $i['name']; // shortcut $s .= " '{$n}' => " . field_default($i) . ",\n"; } $s = substr($s, 0, -2); // remove trailing "," $c = preg_replace('/!!ZOMBIES!!/', $s, $c); // get title field $x = field_get_title_field(); $c = preg_replace('/!!ZOMBIENAME!!/', $x['name'], $c); // create code for form submit field retrieval: $s = ''; foreach ($info as $i) { $n = $i['name']; // shortcut if (is_datetime($i)) { $s .= " \$zitem['{$n}'] = Zombie::getDateTime(Horde_Util::getFormData('{$n}'));\n"; } else { if (is_boolean($i)) { $s .= " \$zitem['{$n}'] = Horde_Util::getFormData('{$n}') ? 1 : 0 ;\n"; } else { $s .= " \$zitem['{$n}'] = Horde_Util::getFormData('{$n}');\n"; } } } return preg_replace('/!!ZOMBIES2!!/', $s, $c); }
/** * Set the adjust duration mix option. * * @param boolean $adjustDuration Use this option to adjust (by repeating or cutting) * the mix files until they have the duration of the first file. * @return void * @throws Stremawide_Media_Exception when parameter is invalid */ public function setAdjustDuration($adjustDuration) { if (is_boolean($adjustDuration)) { $this->_adjustDuration = $adjustDuration; } else { throw new Streamwide_Media_Exception('Parameter must be boolean.'); } }
/** * If no param, returns if we allow sqlite tests. * If param is boolean, set whehter we allow sqlite tests. * @param null|boolean $v * @return boolean */ function allowTestSqlite($v = null) { if (is_null($v)) { return self::$allow_test_sqlite; } else { if (is_boolean($v)) { self::$allow_test_sqlite = $v; } } }
/** * Set secure. * * @return string $secure */ public function setSecure($secure) { if (is_null($secure)) { $this->secure = self::DEFAULT_SECURE; return $this->secure; } if (!is_boolean($secure)) { throw new \Exception("Session security must be a boolean value.", 500); } return $this->secure = $secure; }
/** * Activate or deactivate the join bahavior. * * @param boolean $join whether * @return unknown_type */ public function setJoin($join) { if (!is_boolean($join)) { throw new Streamwide_Media_Exception('Join parameter must be boolean.'); } $this->_join = $join; }
/** * Check and assign variable * * Check a variable using <var>$mode</var> and assigns only if check is * passed. * * Check mode can be one of the following: * - {@link AeTemplate::CHECK_BOOL}: checks if variable can be used in an if * statement * - {@link AeTemplate::CHECK_NUM}: checks if variable can be used as a * number * - {@link AeTemplate::CHECK_TEXT}: checks if variable can be used as text * - {@link AeTemplate::CHECK_LOOP}: (default) checks if variable can be * looped through * - {@link AeTemplate::CHECK_ANY}: checks if variable is not NULL * * This method also supports same formats as {@link AeTemplate::assign()} * method does: <var>$name</var> can be an object, an array or a string. If * <var>$name</var> is an array or an object, <var>$value</var> is expected * to be a check mode instead. * * <b>NOTE:</b> for the {@link AeTemplate::CHECK_BOOL} variable will be * cast to boolean prior to assignment. For the {@link * AeTemplate::CHECK_TEXT} variable will be cast to string * prior to assignment. For the {@link AeTemplate::CHECK_NUM} * variable will be cast to integer, if it is an instance of * {@link AeInteger}, and cast to float, if it is an instance * of {@link AeFloat}. * * @throws AeTemplateException #406 if value doesn't pass the check * * @uses AeTemplate::CHECK_BOOL * @uses AeTemplate::CHECK_NUM * @uses AeTemplate::CHECK_TEXT * @uses AeTemplate::CHECK_LOOP * @uses AeTemplate::CHECK_ANY * * @param object|array|string $name variable name * @param mixed $value variable value * @param int $mode check mode * * @return AeTemplate self */ public function assignCheck($name, $value = null, $mode = self::CHECK_LOOP) { if ($name instanceof AeArray || $name instanceof AeString) { $name = $name->getValue(); } // *** Assign from object if (is_object($name)) { $mode = isset($value) ? $value : self::CHECK_LOOP; foreach (get_object_vars($name) as $key => $value) { $this->assignCheck($key, $value, $mode); } return $this; } // *** Assign from array if (is_array($name)) { $mode = isset($value) ? $value : self::CHECK_LOOP; foreach ($name as $key => $value) { $this->assignCheck($key, $value, $mode); } return $this; } // *** Regular name => value assign if (is_string($name) && $value !== null) { switch ($mode) { case AeTemplate::CHECK_BOOL: if ($value instanceof AeScalar) { $value = $value->toBoolean()->getValue(); } if (!is_scalar($value) && !is_boolean((bool) $value)) { throw new AeTemplateException('Boolean check failed for "' . $name . '" variable', 406); } $value = (bool) $value; break; case AeTemplate::CHECK_NUM: if ($value instanceof AeNumeric) { $value = $value->getValue(); } if (!is_numeric($value)) { throw new AeTemplateException('Numeric check failed for "' . $name . '" variable', 406); } break; case AeTemplate::CHECK_TEXT: if ($value instanceof AeScalar) { $value = $value->toString()->getValue(); } if (!is_scalar($value) || !is_string((string) $value)) { throw new AeTemplateException('Text check failed for "' . $name . '" variable', 406); } $value = (string) $value; break; case AeTemplate::CHECK_ANY: if (is_null($value)) { throw new AeTemplateException('Not null check failed for "' . $name . '" variable', 406); } break; case AeTemplate::CHECK_LOOP: default: if (!is_array($value) && !$value instanceof Traversable) { throw new AeTemplateException('Loop check failed for "' . $name . '" variable', 406); } break; } return $this->assign($name, $value); } throw new AeTemplateException('Invalid value passed: expecting string, array or object, ' . AeType::of($name) . ' given', 400); }