-
Notifications
You must be signed in to change notification settings - Fork 3
/
Region.php
66 lines (59 loc) · 1.57 KB
/
Region.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace Clarifai\DTOs\Predictions;
use Clarifai\DTOs\Crop;
use Clarifai\Internal\_Concept;
use Clarifai\Internal\_Region;
class Region
{
private $id;
/**
* @return string
*/
public function id() { return $this->id; }
private $crop;
/**
* @return Crop
*/
public function crop() { return $this->crop; }
private $concepts;
/**
* @return Concept[]
*/
public function concepts() { return $this->concepts; }
/**
* Ctor.
* @param string $id
* @param Crop $crop
* @param Concept[] $concepts
*/
public function __construct($id, $crop, $concepts)
{
$this->id = $id;
$this->crop = $crop;
$this->concepts = $concepts;
}
/**
* @param _Region $regionResponse
* @return Region
*/
public static function deserialize($regionResponse)
{
$concepts = [];
if (!is_null($regionResponse->getData()) &&
!is_null($regionResponse->getData()->getConcepts())) {
/** @var _Concept $c */
foreach ($regionResponse->getData()->getConcepts() as $c) {
array_push($concepts, Concept::deserialize($c));
}
}
$crop = null;
if (!is_null($regionResponse->getRegionInfo()) &&
!is_null($regionResponse->getRegionInfo()->getBoundingBox())) {
$crop = Crop::deserialize($regionResponse->getRegionInfo()->getBoundingBox());
}
return new Region(
$regionResponse->getId(),
$crop,
$concepts);
}
}