Skip to content

Commit

Permalink
Add Lazy Class Feature
Browse files Browse the repository at this point in the history
  • Loading branch information
DyanGalih committed Jul 2, 2019
1 parent 8e2fc29 commit 8cec5a9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Tools/Lazy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php


namespace WebAppId\DDD\Tools;

/**
* @author: Dyan Galih<[email protected]>
* Date: 2019-07-02
* Time: 07:11
* Class Lazy
* @package WebAppId\DDD\Tools
*/
class Lazy
{
/**
* @param object $fromClass
* @param object $toClass
* @param bool $strict
* @return object
*/
public static function copy(object $fromClass, object $toClass, bool $strict = false): object
{
foreach (get_object_vars($fromClass) as $key => $value) {
if ($strict) {
if (property_exists($toClass, $key)) {
$toClass->$key = $value;
}
} else {
$toClass->$key = $value;
}
}
return $toClass;
}
}

0 comments on commit 8cec5a9

Please sign in to comment.