Welcome Guest, Not a member yet? Register   Sign In
Preventing DRY in OOP
#12

[eluser]InsiteFX[/eluser]
Code:
// -----------------------------------------------------------------------

/**
  * set()
  *
  * Set a registry index and key, value pair.
  *
  * @access public
  * @param string - $index - The registry index
  * @param string - $key  - The registry key
  * @param string - $val  - The registry value
  * @return void
  */
public function set($index, $key, $val)
{
  if ( ! isset($this->reg[$index][$key]))
  {
   $this->reg[$index][$key] = $val;
  }
}

// -----------------------------------------------------------------------

/**
  * get()
  *
  * Gets a registry and value.
  *
  * @access public
  * @param string - $index - The registry index
  * @param string - $key  - The registry key
  * @return mixed - registry string or boolean FALSE
  */
public function get($index, $key)
{
  if (isset($this->reg[$index][$key]))
  {
   return $this->reg[$index][$key];
  }

  return FALSE;
}

// -----------------------------------------------------------------------

/**
  * get_index()
  *
  * Gets the array for this index.
  *
  * @access public
  * @param string - $index
  * @return mixed
  */
    public function get_index($index = NULL)
    {
     if ($index != NULL)
     {
      return $this->reg[$index];
     }

  return FALSE;
    }

// -----------------------------------------------------------------------

/**
  * exists()
  *
  * Checks to see if a registry exists.
  *
  * @access public
  * @param string - $index - The registry index
  * @param string - $key  - The registry key
  * @return bool - TRUE if the registry exists otherwise FALSE.
  */
public function exists($index, $key)
{
  return isset($this->reg[$index][$key]);
}

// -----------------------------------------------------------------------

/**
  * clear()
  *
  * Clears out and resets the registry arrays.
  *
  * @access public
  * @return void
  */
public function clear()
{
  $this->reg = array(array());
}

// -----------------------------------------------------------------------

/**
  * delete()
  *
  * Deletes a registry index key.
  *
  * @access public
  * @param string - $index - The registry index
  * @param string - $key  - The registry key
  * @return bool
  */
public function delete($index, $key)
{
  if (isset($this->reg[$index][$key]))
  {
   unset($this->reg[$index][$key]);
   return TRUE;
  }

  return FALSE;
}

// -----------------------------------------------------------------------

/**
  * debug_registry()
  *
  * Debug the reg arrays.
  *
  * @access public
  * @return array
  */
public function debug_registry()
{
  return $this->reg;
}

} // End of Class


/**
* -------------------------------------------------------------------------
* Filename: Registry.php
* Location: ./application/libraries/Registry.php
* -------------------------------------------------------------------------
*/

Continued below


Messages In This Thread
Preventing DRY in OOP - by El Forum - 01-09-2014, 05:44 AM
Preventing DRY in OOP - by El Forum - 01-09-2014, 10:01 AM
Preventing DRY in OOP - by El Forum - 01-09-2014, 10:33 AM
Preventing DRY in OOP - by El Forum - 01-10-2014, 01:41 AM
Preventing DRY in OOP - by El Forum - 01-10-2014, 05:22 AM
Preventing DRY in OOP - by El Forum - 01-10-2014, 10:11 AM
Preventing DRY in OOP - by El Forum - 01-10-2014, 02:12 PM
Preventing DRY in OOP - by El Forum - 01-11-2014, 05:12 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 05:44 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 05:54 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 06:09 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 06:10 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 06:13 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 06:17 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 06:29 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 06:33 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 07:49 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 07:51 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 07:54 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 09:16 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 09:58 AM
Preventing DRY in OOP - by El Forum - 01-11-2014, 06:09 PM
Preventing DRY in OOP - by El Forum - 01-12-2014, 05:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB