public function generate($obj)
    {
        if (!is_object($obj)) {
            throw new \InvalidArgumentException('OpenGraphGenerator::generate only accept object argument.');
        }

        $openGraph = new OpenGraph();

        $classType = get_class($obj);

        $metadata = $this->factory->getMetadataForClass($classType);

        if (is_array($metadata->namespaces)) {
            foreach ($metadata->namespaces as $namespace) {
                $openGraph->addNamespace($namespace->prefix, $namespace->uri);
            }
        }

        if (is_array($metadata->nodes)) {
            foreach ($metadata->nodes as $graphNode) {
                if (!empty($graphNode['node']->namespaceUri)) {
                    $openGraph->addNamespace($graphNode['node']->namespace, $graphNode['node']->namespaceUri);
                }

                $openGraph->add($graphNode['node']->namespace, $graphNode['node']->tag, $graphNode['object']->getValue($obj));
            }
        }

        return $openGraph;
    }