jkphl / micrometa

A meta parser for extracting micro information out of web documents, currently supporting Microformats 1+2, HTML Microdata, RDFa Lite 1.1, JSON-LD and Link Types, written in PHP
http://micrometa.jkphl.is
MIT License
115 stars 39 forks source link

Unable to get "name" from ListItem -> item #32

Open catalinbozianu opened 5 years ago

catalinbozianu commented 5 years ago

Hi, I can't get the name property from ListItem -> item

Please tell me what can I do.

$items = $micrometa($url, '<script type="application/ld+json">
{
 "@context": "http://schema.org",
 "@type": "BreadcrumbList",
 "itemListElement":
 [
  {
   "@type": "ListItem",
   "position": 1,
   "item":
   {
    "@id": "https://example.com/dresses",
    "name": "Dresses"
    }
  },
  {
   "@type": "ListItem",
  "position": 2,
  "item":
   {
     "@id": "https://example.com/dresses/real",
     "name": "Real Dresses"
   }
  }
 ]
}
</script>');
var_dump($items); exit;

  ["dom":protected]=>
  object(DOMDocument)#1998 (35) {
    ["doctype"]=>
    NULL
    ["implementation"]=>
    string(22) "(object value omitted)"
    ["documentElement"]=>
    string(22) "(object value omitted)"
    ["actualEncoding"]=>
    NULL
    ["encoding"]=>
    NULL
    ["xmlEncoding"]=>
    NULL
    ["standalone"]=>
    bool(true)
    ["xmlStandalone"]=>
    bool(true)
    ["version"]=>
    string(3) "1.0"
    ["xmlVersion"]=>
    string(3) "1.0"
    ["strictErrorChecking"]=>
    bool(true)
    ["documentURI"]=>
    string(9) "/var/www/"
    ["config"]=>
    NULL
    ["formatOutput"]=>
    bool(false)
    ["validateOnParse"]=>
    bool(false)
    ["resolveExternals"]=>
    bool(false)
    ["preserveWhiteSpace"]=>
    bool(true)
    ["recover"]=>
    bool(false)
    ["substituteEntities"]=>
    bool(false)
    ["nodeName"]=>
    string(9) "#document"
    ["nodeValue"]=>
    NULL
    ["nodeType"]=>
    int(9)
    ["parentNode"]=>
    NULL
    ["childNodes"]=>
    string(22) "(object value omitted)"
    ["firstChild"]=>
    string(22) "(object value omitted)"
    ["lastChild"]=>
    string(22) "(object value omitted)"
    ["previousSibling"]=>
    NULL
    ["nextSibling"]=>
    NULL
    ["attributes"]=>
    NULL
    ["ownerDocument"]=>
    NULL
    ["namespaceURI"]=>
    NULL
    ["prefix"]=>
    string(0) ""
    ["localName"]=>
    NULL
    ["baseURI"]=>
    string(9) "/var/www/"
    ["textContent"]=>
    string(315) " { "@context": "http://schema.org", "@type": "BreadcrumbList", "itemListElement": [ { "@type": "ListItem", "position": 1, "item": { "@id": "https://example.com/dresses", "name": "Dresses" } }, { "@type": "ListItem", "position": 2, "item": { "@id": "https://example.com/dresses/real", "name": "Real Dresses" } } ] } "
  }
  ["links":protected]=>
  NULL
  ["items":protected]=>
  array(1) {
    [0]=>
    object(Jkphl\Micrometa\Ports\Item\Item)#2429 (3) {
      ["item":protected]=>
      object(Jkphl\Micrometa\Application\Item\Item)#4104 (8) {
        ["format":protected]=>
        int(4)
        ["value":protected]=>
        NULL
        ["children":protected]=>
        array(0) {
        }
        ["propertyListFactory":protected]=>
        object(Jkphl\Micrometa\Application\Factory\PropertyListFactory)#3988 (0) {
        }
        ["type":protected]=>
        array(1) {
          [0]=>
          object(Jkphl\Micrometa\Domain\Item\Iri)#2514 (2) {
            ["immutableProfile":protected]=>
            string(18) "http://schema.org/"
            ["immutableName":protected]=>
            string(14) "BreadcrumbList"
          }
        }
        ["properties":protected]=>
        object(Jkphl\Micrometa\Application\Item\PropertyList)#4105 (6) {
          ["aliases":protected]=>
          array(1) {
            ["http://schema.org/itemListElement"]=>
            array(1) {
              [0]=>
              string(15) "itemListElement"
            }
          }
          ["aliasFactory":protected]=>
          object(Jkphl\Micrometa\Application\Factory\AliasFactory)#4103 (0) {
          }
          ["values":protected]=>
          array(1) {
            [0]=>
            array(2) {
              [0]=>
              object(Jkphl\Micrometa\Application\Item\Item)#3986 (8) {
                ["format":protected]=>
                int(4)
                ["value":protected]=>
                NULL
                ["children":protected]=>
                array(0) {
                }
                ["propertyListFactory":protected]=>
                object(Jkphl\Micrometa\Application\Factory\PropertyListFactory)#3988 (0) {
                }
                ["type":protected]=>
                array(1) {
                  [0]=>
                  object(Jkphl\Micrometa\Domain\Item\Iri)#4109 (2) {
                    ["immutableProfile":protected]=>
                    string(18) "http://schema.org/"
                    ["immutableName":protected]=>
                    string(8) "ListItem"
                  }
                }
                ["properties":protected]=>
                object(Jkphl\Micrometa\Application\Item\PropertyList)#4108 (6) {
                  ["aliases":protected]=>
                  array(2) {
                    ["http://schema.org/item"]=>
                    array(1) {
                      [0]=>
                      string(4) "item"
                    }
                    ["http://schema.org/position"]=>
                    array(1) {
                      [0]=>
                      string(8) "position"
                    }
                  }
                  ["aliasFactory":protected]=>
                  object(Jkphl\Micrometa\Application\Factory\AliasFactory)#4094 (0) {
                  }
                  ["values":protected]=>
                  array(2) {
                    [0]=>
                    array(1) {
                      [0]=>
                      object(Jkphl\Micrometa\Application\Value\StringValue)#3998 (2) {
                        ["value":protected]=>
                        string(27) "https://example.com/dresses"
                        ["language":protected]=>
                        NULL
                      }
                    }
                    [1]=>
                    array(1) {
                      [0]=>
                      object(Jkphl\Micrometa\Application\Value\StringValue)#4006 (2) {
                        ["value":protected]=>
                        string(1) "1"
                        ["language":protected]=>
                        NULL
                      }
                    }
                  }
                  ["names":protected]=>
                  array(2) {
                    [0]=>
                    object(Jkphl\Micrometa\Domain\Item\Iri)#4093 (2) {
                      ["immutableProfile":protected]=>
                      string(18) "http://schema.org/"
                      ["immutableName":protected]=>
                      string(4) "item"
                    }
                    [1]=>
                    object(Jkphl\Micrometa\Domain\Item\Iri)#4098 (2) {
                      ["immutableProfile":protected]=>
                      string(18) "http://schema.org/"
                      ["immutableName":protected]=>
                      string(8) "position"
                    }
                  }
                  ["nameToCursor":protected]=>
                  array(2) {
                    ["http://schema.org/item"]=>
                    int(0)
                    ["http://schema.org/position"]=>
                    int(1)
                  }
                  ["cursor":protected]=>
                  int(0)
                }
                ["itemId":protected]=>
                string(4) "_:b1"
                ["itemLanguage":protected]=>
                NULL
              }
              [1]=>
              object(Jkphl\Micrometa\Application\Item\Item)#4100 (8) {
                ["format":protected]=>
                int(4)
                ["value":protected]=>
                NULL
                ["children":protected]=>
                array(0) {
                }
                ["propertyListFactory":protected]=>
                object(Jkphl\Micrometa\Application\Factory\PropertyListFactory)#3988 (0) {
                }
                ["type":protected]=>
                array(1) {
                  [0]=>
                  object(Jkphl\Micrometa\Domain\Item\Iri)#4097 (2) {
                    ["immutableProfile":protected]=>
                    string(18) "http://schema.org/"
                    ["immutableName":protected]=>
                    string(8) "ListItem"
                  }
                }
                ["properties":protected]=>
                object(Jkphl\Micrometa\Application\Item\PropertyList)#4101 (6) {
                  ["aliases":protected]=>
                  array(2) {
                    ["http://schema.org/item"]=>
                    array(1) {
                      [0]=>
                      string(4) "item"
                    }
                    ["http://schema.org/position"]=>
                    array(1) {
                      [0]=>
                      string(8) "position"
                    }
                  }
                  ["aliasFactory":protected]=>
                  object(Jkphl\Micrometa\Application\Factory\AliasFactory)#4095 (0) {
                  }
                  ["values":protected]=>
                  array(2) {
                    [0]=>
                    array(1) {
                      [0]=>
                      object(Jkphl\Micrometa\Application\Value\StringValue)#4102 (2) {
                        ["value":protected]=>
                        string(32) "https://example.com/dresses/real"
                        ["language":protected]=>
                        NULL
                      }
                    }
                    [1]=>
                    array(1) {
                      [0]=>
                      object(Jkphl\Micrometa\Application\Value\StringValue)#4096 (2) {
                        ["value":protected]=>
                        string(1) "2"
                        ["language":protected]=>
                        NULL
                      }
                    }
                  }
                  ["names":protected]=>
                  array(2) {
                    [0]=>
                    object(Jkphl\Micrometa\Domain\Item\Iri)#4078 (2) {
                      ["immutableProfile":protected]=>
                      string(18) "http://schema.org/"
                      ["immutableName":protected]=>
                      string(4) "item"
                    }
                    [1]=>
                    object(Jkphl\Micrometa\Domain\Item\Iri)#4076 (2) {
                      ["immutableProfile":protected]=>
                      string(18) "http://schema.org/"
                      ["immutableName":protected]=>
                      string(8) "position"
                    }
                  }
                  ["nameToCursor":protected]=>
                  array(2) {
                    ["http://schema.org/item"]=>
                    int(0)
                    ["http://schema.org/position"]=>
                    int(1)
                  }
                  ["cursor":protected]=>
                  int(0)
                }
                ["itemId":protected]=>
                string(4) "_:b2"
                ["itemLanguage":protected]=>
                NULL
              }
            }
          }
          ["names":protected]=>
          array(1) {
            [0]=>
            object(Jkphl\Micrometa\Domain\Item\Iri)#2526 (2) {
              ["immutableProfile":protected]=>
              string(18) "http://schema.org/"
              ["immutableName":protected]=>
              string(15) "itemListElement"
            }
          }
          ["nameToCursor":protected]=>
          array(1) {
            ["http://schema.org/itemListElement"]=>
            int(0)
          }
          ["cursor":protected]=>
          int(0)
        }
        ["itemId":protected]=>
        string(4) "_:b0"
        ["itemLanguage":protected]=>
        NULL
      }
      ["items":protected]=>
      array(0) {
      }
      ["pointer":protected]=>
      int(0)
    }
  }
  ["pointer":protected]=>
  int(0)
}