Skip to content

Instantly share code, notes, and snippets.

@hiromitz
Created November 16, 2010 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiromitz/701310 to your computer and use it in GitHub Desktop.
Save hiromitz/701310 to your computer and use it in GitHub Desktop.
Abstract Model class
<?php
/**
* Abstract Model class
*/
abstract class Abstract
{
/**
* stored values
* @var mixed
*/
protected $_value;
public function __set(string $key, $value)
{
$this->_value[$key] = $value;
}
public function __get($key)
{
return $this->_value[$key];
}
/**
* Store Value
* return class object for key chain
*
* @param string $key
* @param mixed $value
*/
public function setValue(string $key, $value)
{
$this->_value[$key] = $value;
return $this;
}
/**
* Store values
* @param array $array
*/
public function setValues(array $array)
{
foreach($array as $key => $value) {
$this->_value[$key] = $value;
}
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment