139,6 → 139,7 |
* Maps the values of an associative array to a model object |
* |
* @param array $data |
* Data to be mapped to properties of the object |
* @param array $mapping = null |
* <p>If <var>$mapping</var> is not provided, or <code>null</code> (default), |
* the values of <var>$data</var> are mapped to properties of |
150,13 → 151,11 |
* in <var>$data</var> is not mapped; if a key is missing in |
* <var>$mapping</var>, the value is mapped as if <var>$mapping</var> |
* was <code>null</code>.</p> |
* @param bool $exclusive |
* If <code>true</code>, <em>only</em> the keys of $data that are present |
* in $mapping are mapped. |
* @throws InvalidArgumentException if <var>$mapping</var> is neither |
* <code>null</code> nor an array. |
* @param bool $exclusive = false |
* <p>If <code>true</code>, <em>only</em> the keys of $data that are present |
* in $mapping are mapped.</p> |
*/ |
public function map($data, $mapping = null, $exclusive = false) |
public function map(array $data, array $mapping = null, $exclusive = false) |
{ |
if (is_null($mapping)) |
{ |
165,7 → 164,7 |
$this->$key = $value; |
} |
} |
else if (is_array($mapping)) |
else |
{ |
foreach ($data as $key => $value) |
{ |
182,11 → 181,5 |
} |
} |
} |
else |
{ |
throw new InvalidArgumentException( |
'Expected null or array for $mapping, saw <pre>' |
. print_r($mapping, true) . '</pre>'); |
} |
} |
} |