1<?php
2
3declare(strict_types=1);
4
5namespace Sabre\DAV;
6
7/**
8 * The ICollection Interface.
9 *
10 * This interface should be implemented by each class that represents a collection
11 *
12 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
13 * @author Evert Pot (http://evertpot.com/)
14 * @license http://sabre.io/license/ Modified BSD License
15 */
16interface ICollection extends INode
17{
18    /**
19     * Creates a new file in the directory.
20     *
21     * Data will either be supplied as a stream resource, or in certain cases
22     * as a string. Keep in mind that you may have to support either.
23     *
24     * After successful creation of the file, you may choose to return the ETag
25     * of the new file here.
26     *
27     * The returned ETag must be surrounded by double-quotes (The quotes should
28     * be part of the actual string).
29     *
30     * If you cannot accurately determine the ETag, you should not return it.
31     * If you don't store the file exactly as-is (you're transforming it
32     * somehow) you should also not return an ETag.
33     *
34     * This means that if a subsequent GET to this new file does not exactly
35     * return the same contents of what was submitted here, you are strongly
36     * recommended to omit the ETag.
37     *
38     * @param string          $name Name of the file
39     * @param resource|string $data Initial payload
40     *
41     * @return string|null
42     */
43    public function createFile($name, $data = null);
44
45    /**
46     * Creates a new subdirectory.
47     *
48     * @param string $name
49     */
50    public function createDirectory($name);
51
52    /**
53     * Returns a specific child node, referenced by its name.
54     *
55     * This method must throw Sabre\DAV\Exception\NotFound if the node does not
56     * exist.
57     *
58     * @param string $name
59     *
60     * @return INode
61     */
62    public function getChild($name);
63
64    /**
65     * Returns an array with all the child nodes.
66     *
67     * @return INode[]
68     */
69    public function getChildren();
70
71    /**
72     * Checks if a child-node with the specified name exists.
73     *
74     * @param string $name
75     *
76     * @return bool
77     */
78    public function childExists($name);
79}
80