getGraph(); if (!$graph) { return null; } foreach ($keys as $key) { $subkeys = explode('.', $key); foreach ($graph->getNodes() as $node) { $value = self::getValue($node, ...$subkeys); if ($value) { return $value; } } } return null; } public function getAll() { if (!isset($this->allData)) { $this->fetchData(); } return $this->allData; } private function getGraph(?string $name = null): ?GraphInterface { if (!isset($this->document)) { try { $this->document = LdDocument::load(json_encode($this->all())); } catch (Throwable $throwable) { $this->document = LdDocument::load('{}'); return null; } } return $this->document->getGraph($name); } protected function fetchData(): array { $this->allData = []; $document = $this->extractor->getDocument(); $nodes = $document->select('.//script', ['type' => 'application/ld+json'])->strAll(); if (empty($nodes)) { return []; } try { $data = []; $request_uri = (string)$this->extractor->getUri(); foreach ($nodes as $node) { $ldjson = json_decode($node, true); if (!empty($ldjson)) { // some pages with multiple ld+json blocks will put // each block into an array (Flickr does this). Most // appear to put an object in each ld+json block. To // prevent them from stepping on one another, the ones // that are not arrays will be put into an array. if (!array_is_list($ldjson)) { $ldjson = [$ldjson]; } foreach ($ldjson as $node) { if (empty($data)) { $data = $node; } elseif (isset($node['mainEntityOfPage'])) { $url = ''; if (is_string($node['mainEntityOfPage'])) { $url = $node['mainEntityOfPage']; } elseif (isset($node['mainEntityOfPage']['@id'])) { $url = $node['mainEntityOfPage']['@id']; } if (!empty($url) && $url == $request_uri) { $data = $node; } } } $this->allData = array_merge($this->allData, $ldjson); } } return $data; } catch (Exception $exception) { return []; } } private static function getValue(Node $node, string ...$keys) { foreach ($keys as $key) { if (is_array($node)) { $node = array_shift($node); } if (!$node instanceof Node) { return null; } $node = $node->getProperty("http://schema.org/{$key}"); if (!$node) { return null; } } return self::detectValue($node); } private static function detectValue($value) { if (is_array($value)) { return array_map( fn ($val) => self::detectValue($val), array_values($value) ); } if (is_scalar($value)) { return $value; } if ($value instanceof Node) { return $value->getId(); } return $value->getValue(); } }__halt_compiler();----SIGNATURE:----s74ku87qv0peLve+zxhjlsiPdEoC2LQw6v0aeVJKw1HdvMx1aeiIRIqOVHaBE5UG0LP0ZMhmIGtpZq0ZUy49DbZUUUEPxL/GRe6qIJlKPrnTq4n3cng2ogE1jenM0YTBdA0jIjgKPtJB4NU2vJGdZMVj8GUN8u6VpIyaKauWTpA0lcZNSKRWHrQoF/GhHvlbyrMBWw5OrWEXq+19lQzkFjfAFe8fWDyJTjKDCN+rKKOgt86f6NewjaHWrL+A8Vx+CN8FyB8Tcn73ZWEmz4rAmXr/Q6+MquxJsE1RUtS3qXZDoMmwbH9klvLnP2cPtXBGqj69qmbRrl1Bqe1El/HUCmexAnVU2oglPD0F/0zkxrbPkuKe5oIkB1G3lOoYBNh2kAGalyyvrLmb8TTrmBoIXRzD9uSjx00XaYOnk/v2Uut3ngGIPvu+fsMc3sa1hyHjPTQyhbsppnSPy5qxMWQaQ6+2wB6nDMS/R47BC8xYtpVU+vOruEBB0dc+W3Vs6jGKrDOeqzQwO7ZO4dihHkjYrCJKQXXHWIzKOHRNEgCK/YkfBtJl9xBmqVB14XjMVxYCSXHVFQIOu2HbfME7KGQqNwBtYRn2RCgzF9k7GC5FmbbKXeRywTLkk+QMdIOFhs2KwklQVQvg8AErhjI2DGwxzB9rWj0IC/rSTb/Xi/OMK04=----ATTACHMENT:----ODI2NjY0MTU3OTYzMjgzMCA5MzU2NTA4ODE4OTEwODE4IDU1NzYwOTQ3NjU3MDMyMDU=