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 $apiKey;
13:
14: protected $start;
15:
16: protected $count;
17:
18: protected $query;
19:
20: protected $view;
21:
22: public function __construct(ScopusApi $searchApi, $query)
23: {
24: $this->searchApi = $searchApi;
25: $this->apiKey = $searchApi->getApiKey();
26: $this->query = $query;
27: $this->start = 0;
28: $this->count = 25;
29: $this->view = self::VIEW_STANDARD;
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 getView()
66: {
67: return $this->view;
68: }
69:
70: public function viewStandard()
71: {
72: $this->view = self::VIEW_STANDARD;
73: return $this;
74: }
75:
76: public function viewComplete()
77: {
78: $this->view = self::VIEW_COMPLETE;
79: return $this;
80: }
81:
82: 83: 84:
85: public function search()
86: {
87: return $this->searchApi->search($this->toArray());
88: }
89:
90: public function toArray()
91: {
92: return [
93: 'query' => $this->query,
94: 'start' => $this->start,
95: 'count' => $this->count,
96: 'view' => $this->view,
97: 'apiKey' => $this->apiKey,
98: ];
99: }
100: }