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 boolean|string $uid unique identifier, if required |
||
47 | * @return mixed |
||
48 | */ |
||
49 | public function insert($id, array $fields, $uid = false) |
||
56 | |||
57 | /** |
||
58 | * @param string $keyword |
||
59 | * @param string $value |
||
60 | * @param string $type |
||
61 | * @return Field |
||
62 | */ |
||
63 | private function field($keyword, $value, $type = 'keyword') |
||
67 | |||
68 | /** |
||
69 | * @param Document $document |
||
70 | * @param bool $uid |
||
71 | * @return Document |
||
72 | */ |
||
73 | private function addUid(Document $document, $uid = false) |
||
81 | |||
82 | /** |
||
83 | * @param Document $document |
||
84 | * @param array $fields |
||
85 | * @return Document |
||
86 | */ |
||
87 | private function addFields(Document $document, array $fields) |
||
95 | } |
||
96 |
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: