|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of plumphp/plum. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Florian Eckerstorfer <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
namespace Plum\Plum; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Result. |
|
15
|
|
|
* |
|
16
|
|
|
* @author Florian Eckerstorfer <[email protected]> |
|
17
|
|
|
* @copyright 2014-2016 Florian Eckerstorfer |
|
18
|
|
|
*/ |
|
19
|
|
|
class Result |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var int */ |
|
22
|
|
|
private $readCount = 0; |
|
23
|
|
|
|
|
24
|
|
|
/** @var int */ |
|
25
|
|
|
private $writeCount = 0; |
|
26
|
|
|
|
|
27
|
|
|
/** @var int */ |
|
28
|
|
|
private $itemWriteCount = 0; |
|
29
|
|
|
|
|
30
|
|
|
/** @var \Exception[] */ |
|
31
|
|
|
private $exceptions = []; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @return Result |
|
35
|
|
|
*/ |
|
36
|
1 |
|
public function incReadCount() |
|
37
|
|
|
{ |
|
38
|
1 |
|
++$this->readCount; |
|
39
|
|
|
|
|
40
|
1 |
|
return $this; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return int |
|
45
|
|
|
*/ |
|
46
|
1 |
|
public function getReadCount() |
|
47
|
|
|
{ |
|
48
|
1 |
|
return $this->readCount; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @return Result |
|
53
|
|
|
*/ |
|
54
|
1 |
|
public function incWriteCount() |
|
55
|
|
|
{ |
|
56
|
1 |
|
++$this->writeCount; |
|
57
|
|
|
|
|
58
|
1 |
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Returns the write count of the result. This counter is incremented every time an item is written to a writer. If |
|
63
|
|
|
* an item is written to multiple writers, the counter is increased multiple times for every item. For example, when |
|
64
|
|
|
* 3 items are written to 2 writers each then the write count will be 6. |
|
65
|
|
|
* |
|
66
|
|
|
* @return int |
|
67
|
|
|
*/ |
|
68
|
1 |
|
public function getWriteCount() |
|
69
|
|
|
{ |
|
70
|
1 |
|
return $this->writeCount; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return Result |
|
75
|
|
|
*/ |
|
76
|
1 |
|
public function incItemWriteCount() |
|
77
|
|
|
{ |
|
78
|
1 |
|
++$this->itemWriteCount; |
|
79
|
|
|
|
|
80
|
1 |
|
return $this; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Returns the item write count of the result. This counter is incremented every time an item is written. Every |
|
85
|
|
|
* item can only increase this counter by 1. For example, when 3 items are written to 2 writers each then the |
|
86
|
|
|
* item write count will be 3. |
|
87
|
|
|
* |
|
88
|
|
|
* @return int |
|
89
|
|
|
*/ |
|
90
|
1 |
|
public function getItemWriteCount() |
|
91
|
|
|
{ |
|
92
|
1 |
|
return $this->itemWriteCount; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @param \Exception $exception |
|
97
|
|
|
* |
|
98
|
|
|
* @return Result |
|
99
|
|
|
*/ |
|
100
|
1 |
|
public function addException(\Exception $exception) |
|
101
|
|
|
{ |
|
102
|
1 |
|
$this->exceptions[] = $exception; |
|
103
|
|
|
|
|
104
|
1 |
|
return $this; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return int |
|
109
|
|
|
*/ |
|
110
|
1 |
|
public function getErrorCount() |
|
111
|
|
|
{ |
|
112
|
1 |
|
return count($this->exceptions); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @return \Exception[] |
|
117
|
|
|
*/ |
|
118
|
1 |
|
public function getExceptions() |
|
119
|
|
|
{ |
|
120
|
1 |
|
return $this->exceptions; |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
|