File: GraphInterface.php

package info (click to toggle)
php-ml-json-ld 1.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 628 kB
  • sloc: php: 4,521; makefile: 21
file content (117 lines) | stat: -rw-r--r-- 3,481 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php

/*
 * (c) Markus Lanthaler <mail@markus-lanthaler.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ML\JsonLD;

/**
 * JSON-LD graph interface
 *
 * @author Markus Lanthaler <mail@markus-lanthaler.com>
 */
interface GraphInterface
{
    /**
     * Creates a new node which is linked to this document
     *
     * If a blank node identifier or an invalid ID is passed, the ID will be
     * ignored and a new blank node identifier unique to the document is
     * created for the node.
     *
     * If there exists already a node with the passed ID in the document,
     * that node will be returned instead of creating a new one.
     *
     * @param null|string $id              The ID of the node.
     * @param bool        $preserveBnodeId If set to false, blank nodes are
     *                                     relabeled to avoid collisions;
     *                                     otherwise the blank node identifier
     *                                     is preserved.
     *
     * @return Node The newly created node.
     */
    public function createNode($id = null, $preserveBnodeId = false);

    /**
     * Removes a node from the document
     *
     * This will also eliminate all references to the node within the
     * document.
     *
     * @param NodeInterface $node The node to remove from the document.
     *
     * @return self
     */
    public function removeNode(NodeInterface $node);

    /**
     * Get all nodes
     *
     * @return Node[] Returns an array containing all nodes defined in the
     *                document.
     */
    public function getNodes();

    /**
     * Get a node by ID
     *
     * @param string $id The ID of the node to retrieve.
     *
     * @return Node|null Returns the node if found; null otherwise.
     */
    public function getNode($id);

    /**
     * Get nodes by type
     *
     * @param string|Node $type The type
     *
     * @return Node[] Returns an array containing all nodes of the specified
     *                type in the document.
     */
    public function getNodesByType($type);

    /**
     * Check whether the document already contains a node with the
     * specified ID
     *
     * @param string|Node $id The node ID to check. Blank node identifiers
     *                        will always return false except a node instance
     *                        which is part of the document will be passed
     *                        instead of a string.
     *
     * @return bool Returns true if the document contains a node with the
     *              specified ID; false otherwise.
     */
    public function containsNode($id);

    /**
     * Get the document the node belongs to
     *
     * @return null|DocumentInterface Returns the document the node belongs
     *                                to or null if the node doesn't belong
     *                                to any document.
     */
    public function getDocument();

    /**
     * Removes the graph from the document
     *
     * @return self
     */
    public function removeFromDocument();

    /**
     * Merges the specified graph into the current graph
     *
     * @param GraphInterface $graph The graph that should be merged into the
     *                              current graph.
     *
     * @return self
     */
    public function merge(GraphInterface $graph);
}