forked from liip/LiipHelloBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResponse.php
45 lines (36 loc) · 930 Bytes
/
Response.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
<?php
namespace Liip\HelloBundle;
use JMS\Serializer\Annotation as Serializer;
use Doctrine\Common\Collections\ArrayCollection,
Doctrine\Common\Collections\Collection;
class Response
{
/**
* @var Collection
* @Serializer\XmlList(inline = true, entry = "article")
*/
protected $articles;
/**
* @var int
* @Serializer\XmlAttribute()
*/
protected $page;
public function __construct($articles, $page)
{
if (is_array($articles)) {
$articles = new ArrayCollection($articles);
} elseif (!$articles instanceof Collection) {
throw new \RuntimeException('Response requires a Collection or an array');
}
$this->articles = $articles;
$this->page = $page;
}
public function getArticles()
{
return $this->articles;
}
public function getPage()
{
return $this->page;
}
}