Subversion Repositories PHPX

Compare Revisions

Last modification

Ignore whitespace Rev 48 → Rev 49

/trunk/AbstractModel.php
28,7 → 28,7
* @param array $data Initialization data (optional)
* @param array $mapping Mapping for initialization data (optional)
*/
public function __construct(array $data = null, array $mapping = null)
protected function __construct(array $data = null, array $mapping = null)
{
if (!is_null($data))
{
35,7 → 35,7
$this->map($data, $mapping);
}
}
 
/**
* Getter for properties
*
51,22 → 51,22
$class = get_class($this);
return $class::${$name};
}
 
$method = 'get' . ucfirst($name);
 
if (method_exists($this, $method))
{
return $this->$method();
}
 
if (property_exists($this, "_$name"))
{
return $this->{"_$name"};
}
 
return $this->$name;
}
 
/**
* Setter for properties
*
77,18 → 77,18
public function __set($name, $value)
{
$method = 'set' . ucfirst($name);
 
if (method_exists($this, $method))
{
return $this->$method($value);
}
 
if (property_exists($this, "_$name"))
{
$this->{"_$name"} = $value;
return $this->{"_$name"};
}
 
/* NOTE: Attempts to set other properties are _silently_ _ignored_ */
}
 
104,7 → 104,7
{
return preg_match('/^_\\w/', $varName) > 0;
}
 
/**
* Returns <code>true</code> if a variable name is a property variable name
* (starts with <tt>$_</tt>), <code>false</code> otherwise.
117,7 → 117,7
{
return preg_replace('/^_(\\w)/', '\\1', $varName);
}
 
/**
* Returns the public names of the property variables of a {@link Model}
* as an array of strings
134,7 → 134,7
)
);
}
 
/**
* Maps the values of an associative array to a model object
*
154,6 → 154,8
* @param bool $exclusive = false
* <p>If <code>true</code>, <em>only</em> the keys of $data that are present
* in $mapping are mapped.</p>
* @return AbstractModel
* The modified object
*/
public function map(array $data, array $mapping = null, $exclusive = false)
{
181,5 → 183,7
}
}
}
 
return $this;
}
}