Total Complexity | 4 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class SearchResult |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | public $documentPath; |
||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | public $matchingTokens; |
||
24 | /** |
||
25 | * @var float |
||
26 | */ |
||
27 | public $score; |
||
28 | |||
29 | protected $document; |
||
30 | /** |
||
31 | * @var Storage |
||
32 | */ |
||
33 | protected $storage; |
||
34 | |||
35 | /** |
||
36 | * @return Document |
||
37 | * @throws \Exception |
||
38 | */ |
||
39 | public function getDocument() |
||
40 | { |
||
41 | if ($this->document instanceof Document) { |
||
42 | return $this->document; |
||
43 | } else { |
||
44 | $this->document = $this->storage->getDocuments()->getDocumentBySlug(substr($this->documentPath, 1)); |
||
45 | if ($this->document !== false) { |
||
|
|||
46 | $this->document->dbHandle = $this->storage->getContentDbHandle(); |
||
47 | $this->document->documentStorage = $this->storage->getDocuments(); |
||
48 | } |
||
49 | |||
50 | return $this->document; |
||
51 | } |
||
52 | } |
||
53 | |||
54 | public function setStorage($storage) |
||
57 | } |
||
58 | } |