-
Notifications
You must be signed in to change notification settings - Fork 27
/
ResolveResponse.php
50 lines (43 loc) · 1.03 KB
/
ResolveResponse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Factual;
/**
* Represents the response from running a fetch request against Factual, such as
* a geolocation based query for specific places entities.
* This is a refactoring of the Factual Driver by Aaron: https://github.com/Factual/factual-java-driver
* @author Tyler
* @package Factual
* @license Apache 2.0
*/
class ResolveResponse extends ReadResponse {
/**
* Checks whether query was resolved
* @return bool
*/
public function isResolved() {
return (bool) $this->data[0]['resolved'];
}
/**
* Gets resolved entity as array
* @return array | false on no resolution
*/
public function getResolved() {
if ($this->isResolved()) {
return $this->data[0];
} else {
return null;
}
}
/*
* Gets resolved entity as object (experimental)
* @return array | false on no resolution
public function getResolvedAsObject() {
if ($this->isResolved() && $this->entityType) {
$objectType = $this->entityType;
return new $objectType ($this->data[0]);
} else {
return null;
}
}
*/
}
?>