Php 如何在几行代码中将大量数组键重构为对象属性?

Php 如何在几行代码中将大量数组键重构为对象属性?,php,refactoring,Php,Refactoring,我有这样的代码(完整代码有47行): $this->outline->value=$row['value']; $this->outline->some_value=$row['some_value']; $this->outline->specs=$row['specs']; $this->outline->second_marker=$row['second_marker']; $this->outline->holes=$row['holes']; 如何在保持相同功能的同时使其变小?@D

我有这样的代码(完整代码有47行):

$this->outline->value=$row['value'];
$this->outline->some_value=$row['some_value'];
$this->outline->specs=$row['specs'];
$this->outline->second_marker=$row['second_marker'];
$this->outline->holes=$row['holes'];

如何在保持相同功能的同时使其变小?

@Dennis:如果您经常这样做,请将此作为
outline
so
$this->outline->setProps($row)的一种方法
或类
$this
中的方法引用的是
setObjProps($this->outline,$row)
foreach ($row as $key => $value) {
    $this->outline->{$key} = $value;
}