Passed
Push — develop ( 169afe...f2bd80 )
by Jens
02:39
created

SearchResult   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDocument() 0 10 2
A setStorage() 0 4 1
1
<?php
2
/**
3
 * User: jensk
4
 * Date: 3-3-2017
5
 * Time: 16:56
6
 */
7
8
namespace library\search\results;
9
10
11
use library\storage\Document;
12
use library\storage\JsonStorage;
13
use library\storage\Repository;
14
15
class SearchResult
16
{
17
	/**
18
	 * @var string
19
	 */
20
	public $documentPath;
21
	/**
22
	 * @var array
23
	 */
24
	public $matchingTokens;
25
	/**
26
	 * @var float
27
	 */
28
	public $score;
29
30
	protected $document;
31
	/**
32
	 * @var JsonStorage
33
	 */
34
	protected $storage;
35
36
	/**
37
	 * @return Document
38
	 */
39
	public function getDocument()
40
	{
41
		if ($this->document instanceof Document) {
42
			return $this->document;
43
		} else {
44
			$this->document = $this->storage->getDocumentBySlug(substr($this->documentPath, 1));
45
			$this->document->dbHandle = $this->storage->getContentDbHandle();
46
			return $this->document;
47
		}
48
	}
49
50
	public function setStorage($storage)
51
	{
52
		$this->storage = $storage;
53
	}
54
}