*/ private $type; /** * The data of the schema piece. * * @var array */ private $data; /** * Class constructor. * * @param array $data The data of the schema piece. * @param string|array $type The type of the schema piece. */ public function __construct( array $data, $type ) { $this->data = $data; $this->type = $type; } /** * Gets the type of the schema piece. * * @return string|array The type(s) of the schema piece. */ public function get_type() { return $this->type; } /** * Gets the data of the schema piece. * * @return array The data of the schema piece. */ public function get_data(): array { return $this->data; } /** * Gets the ID of the schema piece. * * @return string|null The ID of the schema piece, or null if not set. */ public function get_id(): ?string { return ( $this->data['@id'] ?? null ); } /** * Converts multiple schema pieces to a JSON-LD-encoded graph. * * @return array The JSON-LD graph representation. */ public function to_json_ld_graph(): array { return [ '@graph' => $this->data, ]; } }