original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Generate OpenGraph through metadata
  
  @param object $obj
  @return OpenGraphInterface
docstring_tokens: Generate OpenGraph through metadata