Anahkiasen/former — pull request #253 by rmasters (2014-01-13 15:46:29+00:00)
Title: While populating, if the model implements toArray() use that rather than a cast

I'm working with some non-Laravel models atm, and it would be nice to use them with Former's populator. The properties are protected, so when casting to an array you get asterisks prepended to the keys (bah):

class Obj { protected $field; public function setField($val) { $this->field = $val; return $this; } }
var_dump((array) (new Obj)->setField(123));

array(1) { '\0*\0field' => int(123) }

Given that (anecdotally) the method most models use to cast to array is called `toArray`, this checks to see if the method exists first rather than casting. Potentially it could check for `to_array` as well? Thoughts?