1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jacobemerick\Web\Domain\Comment\Commenter; |
4
|
|
|
|
5
|
|
|
use Jacobemerick\CommentService\Api\DefaultApi; |
6
|
|
|
use Jacobemerick\CommentService\Model\Commenter; |
7
|
|
|
|
8
|
|
|
class ServiceCommenterRepository implements CommenterRepositoryInterface |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @var Jacobemerick\CommentService\Api\DefaultApi |
13
|
|
|
*/ |
14
|
|
|
protected $api; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @param Jacobemerick\CommentService\Api\DefaultApi $api |
18
|
|
|
*/ |
19
|
|
|
public function __construct(DefaultApi $api) |
20
|
|
|
{ |
21
|
|
|
$this->api = $api; |
|
|
|
|
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param array $commenter |
26
|
|
|
* @return array |
27
|
|
|
* @throws Jacobemerick\CommentService\ApiException |
28
|
|
|
*/ |
29
|
|
|
public function createCommenter(array $commenter) |
30
|
|
|
{ |
31
|
|
|
$response = $this->api->createCommenter($commenter); |
32
|
|
|
return $this->deserializeCommenter($response); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param integer $commenterId |
37
|
|
|
* @return array |
38
|
|
|
* @throws Jacobemerick\CommentService\ApiException |
39
|
|
|
*/ |
40
|
|
|
public function getCommenter($commenterId) |
41
|
|
|
{ |
42
|
|
|
$response = $this->api->getCommenter($commenterId); |
43
|
|
|
return $this->deserializeCommenter($response); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param integer $page |
48
|
|
|
* @param integer $perPage |
49
|
|
|
* @return array |
50
|
|
|
* @throws Jacobemerick\CommentService\ApiException |
51
|
|
|
*/ |
52
|
|
|
public function getCommenters($page = null, $perPage = null) |
53
|
|
|
{ |
54
|
|
|
$response = $this->api->getCommenters($page, $perPage); |
55
|
|
|
return array_map([$this, 'deserializeCommenter'], $response); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param Jacobemerick\CommentService\Model\Commenter |
60
|
|
|
* @return array |
61
|
|
|
*/ |
62
|
|
|
protected function deserializeCommenter(Commenter $commenter) |
63
|
|
|
{ |
64
|
|
|
return [ |
65
|
|
|
'id' => $commenter->getId(), |
66
|
|
|
'name' => $commenter->getName(), |
67
|
|
|
'website' => $commenter->getWebsite(), |
68
|
|
|
]; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..