Source of file InspectionTrait.php
Size: 0,999 Bytes - Last Modified: 2021-12-23T10:55:43+00:00
/var/www/docs.ssmods.com/process/src/src/InspectionTrait.php
1234567891011121314151617181920212223242526272829303132333435363738394041 | <?php namespace TractorCow\OpenGraph; use SilverStripe\Core\Extensible; trait InspectionTrait { /** * Determine if an object implements a specific interface, or * has an extension which implements this * * @param object $object * @param string $type Type to inspect * @return bool True if $object, or any of its extensions, is of type $type */ protected static function implementsType($object, $type) { if (!is_object($object)) { return false; } if ($object instanceof $type) { return true; } // Check extensions /** @var Extensible $object */ if (in_array(Extensible::class, class_uses($object))) { $extensions = $object->getExtensionInstances(); foreach ($extensions as $extension) { if ($extension instanceof $type) { return true; } } } return false; } } |