File tree Expand file tree Collapse file tree 4 files changed +111
-14
lines changed
Expand file tree Collapse file tree 4 files changed +111
-14
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Spameri \ElasticQuery ;
4+
5+
6+ class Document implements \Spameri \ElasticQuery \Entity \ArrayInterface
7+ {
8+
9+ /**
10+ * @var ?string
11+ */
12+ private $ index ;
13+ /**
14+ * @var ?\Spameri\ElasticQuery\Document\BodyInterface
15+ */
16+ private $ body ;
17+ /**
18+ * @var ?string
19+ */
20+ private $ type ;
21+ /**
22+ * @var ?string
23+ */
24+ private $ id ;
25+ /**
26+ * @var array
27+ */
28+ private $ options ;
29+
30+
31+ public function __construct (
32+ ?string $ index
33+ , ?\Spameri \ElasticQuery \Document \BodyInterface $ body = NULL
34+ , ?string $ type = NULL
35+ , ?string $ id = NULL
36+ , array $ options = []
37+ )
38+ {
39+ $ this ->index = $ index ;
40+ $ this ->body = $ body ;
41+ $ this ->type = $ type ;
42+ $ this ->id = $ id ;
43+ $ this ->options = $ options ;
44+ }
45+
46+
47+ public function toArray () : array
48+ {
49+ $ array = [];
50+
51+ if ($ this ->index ) {
52+ $ array ['index ' ] = $ this ->index ;
53+ }
54+
55+ if ($ this ->body ) {
56+ $ array ['body ' ] = $ this ->body ->toArray ();
57+ }
58+
59+ if ($ this ->type ) {
60+ $ array ['type ' ] = $ this ->type ;
61+ }
62+
63+ if ($ this ->id ) {
64+ $ array ['id ' ] = $ this ->id ;
65+ }
66+
67+ if ($ this ->options ) {
68+ $ array = \array_merge ($ array , $ this ->options );
69+ }
70+
71+ return $ array ;
72+ }
73+
74+ }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Spameri \ElasticQuery \Document \Body ;
4+
5+
6+ class Plain implements \Spameri \ElasticQuery \Document \BodyInterface
7+ {
8+
9+ /**
10+ * @var array
11+ */
12+ private $ parameters ;
13+
14+
15+ public function __construct (
16+ array $ parameters
17+ )
18+ {
19+ $ this ->parameters = $ parameters ;
20+ }
21+
22+
23+ public function toArray () : array
24+ {
25+ return $ this ->parameters ;
26+ }
27+
28+ }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Spameri \ElasticQuery \Document ;
4+
5+
6+ interface BodyInterface extends \Spameri \ElasticQuery \Entity \ArrayInterface
7+ {
8+
9+ }
You can’t perform that action at this time.
0 commit comments