1 | <?php |
||
15 | final class Insert |
||
16 | { |
||
17 | /** |
||
18 | * @var Index |
||
19 | */ |
||
20 | private $index; |
||
21 | |||
22 | /** |
||
23 | * @var Document |
||
24 | */ |
||
25 | private $document; |
||
26 | |||
27 | /** |
||
28 | * Insert constructor. |
||
29 | * |
||
30 | * @param Search $search |
||
31 | * @param Index $index |
||
32 | * @param Document $document |
||
33 | */ |
||
34 | public function __construct(Search $search, Index $index, Document $document) |
||
40 | |||
41 | /** |
||
42 | * Insert |
||
43 | * |
||
44 | * @param $id |
||
45 | * @param array $fields fields that are indexed |
||
46 | * @param array $parameters fields that aren't indexed |
||
47 | * @param boolean|string $uid unique identifier, if required |
||
48 | * @return mixed |
||
49 | */ |
||
50 | public function insert($id, array $fields, array $parameters = [ ], $uid = false) |
||
58 | |||
59 | /** |
||
60 | * @param Document $document |
||
61 | * @param array $parameters |
||
62 | * @return Document |
||
63 | */ |
||
64 | private function addParameters(Document $document, array $parameters = []) |
||
72 | |||
73 | /** |
||
74 | * @param string $keyword |
||
75 | * @param string $value |
||
76 | * @param string $type |
||
77 | * @return Field |
||
78 | */ |
||
79 | private function field($keyword, $value, $type = 'keyword') |
||
83 | |||
84 | /** |
||
85 | * @param Document $document |
||
86 | * @param bool $uid |
||
87 | * @return Document |
||
88 | */ |
||
89 | private function addUid(Document $document, $uid = false) |
||
97 | |||
98 | /** |
||
99 | * @param Document $document |
||
100 | * @param array $fields |
||
101 | * @return Document |
||
102 | */ |
||
103 | private function addFields(Document $document, array $fields) |
||
111 | |||
112 | /** |
||
113 | * @param $parameters |
||
114 | * @return string |
||
115 | * @todo I'm not sure this is the right thing to do here, perhaps do some more investigation. |
||
116 | */ |
||
117 | private function flattenParameters($parameters) |
||
121 | } |
||
122 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: