|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2017 American Express Travel Related Services Company, Inc. |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
|
15
|
|
|
* or implied. See the License for the specific language governing |
|
16
|
|
|
* permissions and limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
declare(strict_types=1); |
|
20
|
|
|
|
|
21
|
|
|
namespace AmericanExpress\HyperledgerFabricClient\Proposal; |
|
22
|
|
|
|
|
23
|
|
|
use Hyperledger\Fabric\Protos\Peer\ProposalResponse; |
|
24
|
|
|
|
|
25
|
|
|
class ResponseCollection |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @var Response[] |
|
29
|
|
|
*/ |
|
30
|
|
|
private $responses; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* ProposalResponseCollection constructor. |
|
34
|
|
|
* @param mixed[] $responses |
|
35
|
|
|
*/ |
|
36
|
4 |
|
public function __construct(array $responses = []) |
|
37
|
|
|
{ |
|
38
|
4 |
|
$this->responses = $responses; |
|
39
|
4 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return ProposalResponse[] |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getProposalResponses(): array |
|
45
|
|
|
{ |
|
46
|
3 |
|
return \array_filter(\array_map(function (Response $response) { |
|
47
|
2 |
|
return $response->getProposalResponse(); |
|
48
|
3 |
|
}, $this->responses)); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @return bool |
|
53
|
|
|
*/ |
|
54
|
3 |
|
public function hasProposalResponses(): bool |
|
55
|
|
|
{ |
|
56
|
3 |
|
return \count($this->getProposalResponses()) > 0; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return \Exception[] |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getExceptions(): array |
|
63
|
|
|
{ |
|
64
|
3 |
|
return \array_filter(\array_map(function (Response $response) { |
|
65
|
2 |
|
return $response->getException(); |
|
66
|
3 |
|
}, $this->responses)); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return bool |
|
71
|
|
|
*/ |
|
72
|
3 |
|
public function hasExceptions(): bool |
|
73
|
|
|
{ |
|
74
|
3 |
|
return \count($this->getExceptions()) > 0; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|