1: <?php
2:
3: namespace vierbergenlars\Forage;
4:
5: use vierbergenlars\Forage\Transport\TransportInterface;
6: use vierbergenlars\Forage\SearchQuery\Query;
7: use vierbergenlars\Forage\SearchQuery\QueryBuilder;
8: use vierbergenlars\Forage\SearchIndex\Index;
9: use vierbergenlars\Forage\ODM\DocumentMapper;
10: use vierbergenlars\Forage\ODM\HydrationSettingsInterface;
11:
12: class Client
13: {
14: /**
15: * The transport to use
16: * @var \vierbergenlars\Forage\Transport\TransportInterface
17: */
18: protected $transport;
19:
20: /**
21: * Creates a new Forage client
22: * @param \vierbergenlars\Forage\Transport\TransportInterface $transport
23: */
24: public function __construct(TransportInterface $transport)
25: {
26: $this->transport = $transport;
27: }
28:
29: /**
30: * Creates a new query builder
31: * @return \vierbergenlars\Forage\SearchQuery\QueryBuilder
32: */
33: public function createQueryBuilder()
34: {
35: $query = new Query($this->transport);
36: return new QueryBuilder($query);
37: }
38:
39: /**
40: * Gets the search index
41: * @return \vierbergenlars\Forage\SearchIndex\Index
42: */
43: public function getIndex()
44: {
45: return new Index($this->transport);
46: }
47:
48: /**
49: * Creates a new document mapper
50: * @param \vierbergenlars\Forage\ODM\HydrationSettingsInterface $hydrationSettings
51: * @return \vierbergenlars\Forage\ODM\DocumentMapper
52: */
53: public function createDocumentMapper(HydrationSettingsInterface $hydrationSettings)
54: {
55: return new DocumentMapper($this->transport, $hydrationSettings);
56: }
57: }
58: