diff --git a/src/Gears/ObjectType.php b/src/Gears/ObjectType.php index 0288b1b..a390bbe 100644 --- a/src/Gears/ObjectType.php +++ b/src/Gears/ObjectType.php @@ -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) *