_base = (empty($base)) ? $GLOBALS[ACFS_TOKEN] : $base; } /** * Get a property based on the provided name. * * @since 1.0.4 Modified for null default value. * @since 1.0.0 * * @access public * @param string $name Name of the property to return. * @return string Property if it is found, otherwise an empty string. */ public function __get($name) { if (!isset($this->_properties[$name]) || is_null($this->_properties[$name])) { return $this->_properties[$name] = $this->_default($name); } return $this->_properties[$name]; } /** * Check to see if a property exists with the provided name. * * @since 1.0.4 Modified to work with empty() calls. * @since 1.0.0 * * @access public * @param string $name Name of the property to check. * @return boolean True if the property is set, otherwise false. */ public function __isset($name) { if (!isset($this->_properties[$name]) || is_null($this->_properties[$name])) { $default = $this->_default($name); if (!is_null($default)) { $this->_properties[$name] = $default; } } return isset($this->_properties[$name]); } /** * Set the property with the provided name to the provided value. * * @since 1.0.0 * * @access public * @param string $name Name of the property to set. * @param string $value Value of the property to set. * @return void */ public function __set($name, $value) { $this->_properties[$name] = $value; } /** * Unset the property with the provided name. * * @since 1.0.0 * * @access public * @param string $name Name of the property to unset. * @return void */ public function __unset($name) { unset($this->_properties[$name]); } /** * Set the initial properties for the object. * * @since 1.0.4 * * @access protected * @param array $defaults Default properties for the object. * @param array $options Optional specific options for the object. * @return void */ protected function _set_properties($defaults, $options = array()) { $defaults = $this->_check_array($defaults); $this->_properties = (empty($options)) ? $defaults : array_merge($defaults, $this->_check_array($options)); } /** * Check a value to see if it is an array or convert to an array if necessary. * * @since 1.0.4 * * @access protected * @param mixed $value Value to turn into an array. * @param mixed $return_false True if a false value should be returned as-is. * @return array Checked value as an array. */ protected function _check_array($value, $return_false = false) { if ($value === false && $return_false) { return $value; } if (empty($value)) { $value = array(); } if (!is_array($value)) { $value = array($value); } return $value; } /** * Get a default property based on the provided name. * * @since 1.0.4 Changed default value to null. * @since 1.0.0 * * @access protected * @param string $name Name of the property to return. * @return string Empty string. */ protected function _default($name) { return null; } /** * Push a value into a property array. * * @since 1.0.4 Modified to allow for the array index to be specified. * @since 1.0.0 * * @access public * @param string $name Name of the property array to push the value into. * @param string $value Value to push into the property array. * @param mixed $index Optional array index for the value to push. * @return void */ public function _push($name, $value, $index = null) { $property = $this->$name; if (is_array($property)) { if (is_null($index)) { $property[] = $value; } else { $property[$index] = $value; } } $this->$name = $property; } } }