1: <?php
2:
3: namespace Scopus\Response;
4:
5: class SearchResults
6: {
7:
8: protected $data;
9:
10:
11: protected $links;
12:
13:
14: protected $entries;
15:
16: public function __construct(array $data)
17: {
18: $this->data = $data;
19: }
20:
21: public function getTotalResults()
22: {
23: return $this->data['opensearch:totalResults'];
24: }
25:
26: public function getStartIndex()
27: {
28: return $this->data['opensearch:startIndex'];
29: }
30:
31: public function getItemsPerPage()
32: {
33: return $this->data['opensearch:itemsPerPage'];
34: }
35:
36: public function getQuery()
37: {
38: return $this->data['opensearch:Query'];
39: }
40:
41: public function getLinks()
42: {
43: return $this->links ?: $this->links = new SearchLinks($this->data['link']);
44: }
45:
46: 47: 48:
49: public function getEntries()
50: {
51: if (isset($this->data['entry'])) {
52: return $this->entries ?: $this->entries = array_map(function($entry) {
53: return new Entry($entry);
54: }, $this->data['entry']);
55: }
56: }
57:
58: public function countEntries()
59: {
60: return isset($this->data['entry']) ? count($this->data['entry']) : 0;
61: }
62: }