Skip to content

Commit

Permalink
Convert classToArray in Model to a public static method that can be c…
Browse files Browse the repository at this point in the history
…alled by those that dare...
  • Loading branch information
lonnieezell committed Jul 6, 2017
1 parent 69b9f68 commit 2d05e64
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ public function save($data)
// them as an array.
if (is_object($data) && ! $data instanceof \stdClass)
{
$data = $this->classToArray($data);
$data = static::classToArray($data);
}

if (is_object($data) && isset($data->{$this->primaryKey}))
Expand Down Expand Up @@ -591,7 +591,7 @@ public function save($data)
*
* @return array
*/
protected function classToArray($data): array
public static function classToArray($data): array
{
$mirror = new \ReflectionClass($data);
$props = $mirror->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED);
Expand Down Expand Up @@ -627,7 +627,7 @@ public function insert($data)
// them as an array.
if (is_object($data) && ! $data instanceof \stdClass)
{
$data = $this->classToArray($data);
$data = static::classToArray($data);
}

// If it's still a stdClass, go ahead and convert to
Expand Down Expand Up @@ -691,7 +691,7 @@ public function update($id, $data)
// them as an array.
if (is_object($data) && ! $data instanceof \stdClass)
{
$data = $this->classToArray($data);
$data = static::classToArray($data);
}

// If it's still a stdClass, go ahead and convert to
Expand Down

0 comments on commit 2d05e64

Please sign in to comment.