Skip to content

Commit

Permalink
Add ObjectType::castClass
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmologist committed Nov 9, 2018
1 parent 36087e5 commit cebb3b5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Gears/ObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ public static function set($object, $propertyPath, $value)
(new PropertyAccessor())->setValue($object, $propertyPath, $value);
}

/**
* Casts target to class name.
*
* @param object|string $target Object or FQCN
*
* @return string FQCN
*/
public static function castClass($target)
{
if (is_object($target)) {
return get_class($target);
}

return $target;
}

/**
* Try to get object string representation (via __toString)
*
Expand Down

0 comments on commit cebb3b5

Please sign in to comment.