/** * Return a GraphObject loaded with data from Facebook Graph API * * @param GraphObjectType $type * @param string|int $id * * @return ObjectAbstract * @throws UnsupportedObjectException unable to find a class to support this */ public static function load(GraphObjectType $type, $id) { $class_name = __NAMESPACE__ . '\\' . $type->value(); if (class_exists($class_name)) { /** @var ObjectAbstract $obj */ $obj = new $class_name(); return $obj; } else { throw new UnsupportedObjectException('Unsupported Object, class not found for ' . $object); } }