1: <?php
2:
3: namespace Scopus;
4:
5: class SearchQuery
6: {
7: const VIEW_STANDARD = 'STANDARD';
8: const VIEW_COMPLETE = 'COMPLETE';
9:
10: protected $searchApi;
11:
12: protected $start;
13:
14: protected $count;
15:
16: protected $query;
17:
18: protected $view;
19:
20: protected $cursor;
21:
22: public function __construct(ScopusApi $searchApi, $query)
23: {
24: $this->searchApi = $searchApi;
25: $this->query = $query;
26: $this->start = 0;
27: $this->count = 25;
28: $this->view = self::VIEW_STANDARD;
29: $this->cursor = null;
30: }
31:
32: public function getStart()
33: {
34: return $this->start;
35: }
36:
37: public function start($startIndex)
38: {
39: $this->start = $startIndex;
40: return $this;
41: }
42:
43: public function getCount()
44: {
45: return $this->count;
46: }
47:
48: public function count($count)
49: {
50: $this->count = $count;
51: return $this;
52: }
53:
54: public function getQuery()
55: {
56: return $this->query;
57: }
58:
59: public function query($query)
60: {
61: $this->query = $query;
62: return $this;
63: }
64:
65: public function withCursor()
66: {
67: $this->cursor = "*";
68: return $this;
69: }
70:
71: public function setCursor($cursor)
72: {
73: $this->cursor = $cursor;
74: return $this;
75: }
76:
77: public function getCursor()
78: {
79: return $this->cursor;
80: }
81:
82: public function getView()
83: {
84: return $this->view;
85: }
86:
87: public function viewStandard()
88: {
89: $this->view = self::VIEW_STANDARD;
90: return $this;
91: }
92:
93: public function viewComplete()
94: {
95: $this->view = self::VIEW_COMPLETE;
96: return $this;
97: }
98:
99: /**
100: * @return Response\SearchResults
101: */
102: public function search()
103: {
104: return $this->searchApi->search($this->toArray());
105: }
106:
107: public function toArray()
108: {
109: return [
110: 'query' => $this->query,
111: 'start' => $this->start,
112: 'count' => $this->count,
113: 'view' => $this->view,
114: 'cursor' => $this->cursor
115: ];
116: }
117: }
118: