Issues (109)

src/EoC/Doc/IDoc.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * @file IDoc.php
5
 * @brief This file contains the IDoc interface.
6
 * @details
7
 * @author Filippo F. Fadda
8
 */
9
10
11
namespace EoC\Doc;
12
13
14
/**
15
 * @brief To become persistent a class must implement at least this interface.
16
 * @details For your convenience you would inherit your persistent classes from Doc or LocalDoc (in case of local
17
 * documents), because they already implements this interface. Else, if your model won't let you do that (PHP doesn't
18
 * support multiple inheritance), you might use the TDoc, since it provides properties and methods to interact
19
 * with CouchDB. As last chance you can implement this interface.
20
 * @nosubgrouping
21
 */
22
interface IDoc {
23
24
  /**
25
   * @brief Sets the full name space class name into the the provided metadata into the metadata array.
26
   * @details The method Couch.getDoc will use this to create an object of the same class you previously stored using
27
   * Couch::saveDoc() method.
28
   * @param string $value The full namespace class name, like returned from get_class() function.
29
   */
30
  function setClass($value);
31
32
33
  /**
34
   * @brief Sets the object type.
35
   * @param string $value Usually the class name purged of his namespace.
36
   */
37
  function setType($value);
38
39
40
  /**
41
   * @brief Returns `true` if your document class already defines his type internally, `false` otherwise.
42
   * @details Sometime happens you have two classes with the same name but located under different namespaces. In case,
43
   * you should provide a type yourself for at least one of these classes, to avoid Couch::saveDoc() using the same type
44
   * for both. Default implementation should return `false`.
45
   * @return bool
46
   */
47
  function hasType();
48
49
50
  /**
51
   * @brief Gets the document path.
52
   * @details Returns an empty string for standard document, `_local/` for local document and `_design/` for
53
   * design document.
54
   * @return string
55
   */
56
  function getPath();
57
58
59
  /**
60
   * @brief Returns the document representation as a JSON object.
61
   * @return JSON object
0 ignored issues
show
The type EoC\Doc\JSON was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
62
   */
63
  function asJson();
64
65
66
  /**
67
   * @brief Returns the document representation as an associative array.
68
   * @return array An associative array
69
   */
70
  public function asArray();
71
72
73
  /**
74
   * @brief Gets the document identifier.
75
   * @return string
76
   */
77
  function getId();
78
79
80
  /**
81
   * @brief Returns `true` if the document has an identifier, `false` otherwise.
82
   * @return bool
83
   */
84
  function issetId();
85
86
87
  /**
88
   * @brief Sets the document identifier. Mandatory and immutable.
89
   */
90
  function setId($value);
91
92
93
  /**
94
   * @brief Unset the document identifier.
95
   */
96
  function unsetId();
97
98
}