Skip to content

Files

Latest commit

22700b2 · Dec 10, 2024

History

History
22 lines (16 loc) · 581 Bytes

objectcopyinterface.md

File metadata and controls

22 lines (16 loc) · 581 Bytes
sidebar_position
3

ObjectCopy Interface

ObjectCopyInterface is an interface that exposes the methods copyFrom and copyTo, which allow you to set property contents from or to another object.

You can either implement this interface or extend the class ObjectCopy.

<?php
// Create the class
class MyClass extends ObjectCopy
{}

// Copy the properties from $data into the properties that match on $myclass
$myclass->copyFrom($data);

// Copy the properties from $myclass into the properties that match on $otherObject
$myclass->copyTo($otherobject);