1
|
|
|
<?php |
2
|
|
|
namespace FilmTools\Developing; |
3
|
|
|
|
4
|
|
|
use FilmTools\Commons\DataLengthMismatchException; |
5
|
|
|
use FilmTools\Commons\FilmToolsInvalidArgumentException; |
6
|
|
|
use FilmTools\Commons\Exposures; |
7
|
|
|
use FilmTools\Commons\ExposuresInterface; |
8
|
|
|
use FilmTools\Commons\ExposuresProviderInterface; |
9
|
|
|
use FilmTools\Commons\Densities; |
10
|
|
|
use FilmTools\Commons\DensitiesInterface; |
11
|
|
|
use FilmTools\Commons\DensitiesProviderInterface; |
12
|
|
|
|
13
|
|
|
class Developing implements DevelopingInterface |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var int |
18
|
|
|
*/ |
19
|
|
|
public $time; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var Exposures |
23
|
|
|
*/ |
24
|
|
|
protected $exposures; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var Densities |
28
|
|
|
*/ |
29
|
|
|
protected $densities; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var array |
33
|
|
|
*/ |
34
|
|
|
protected $data; |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param ExposuresProviderInterface|float[] $exposures |
39
|
|
|
* @param DensitiesProviderInterface|float[] $densities |
40
|
|
|
* @param int $time |
41
|
|
|
*/ |
42
|
48 |
|
public function __construct( $exposures, $densities, int $time) |
43
|
|
|
{ |
44
|
48 |
|
$this->setExposures( $exposures ); |
45
|
48 |
|
$this->setDensities( $densities ); |
46
|
|
|
|
47
|
48 |
|
if (count($this->getExposures()) != count( $this->getDensities() )) |
48
|
6 |
|
throw new DataLengthMismatchException; |
49
|
|
|
|
50
|
42 |
|
$this->resetData(); |
51
|
|
|
|
52
|
42 |
|
$this->time = $time; |
53
|
42 |
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
|
57
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @inheritDoc |
61
|
|
|
*/ |
62
|
12 |
|
public function getTime(): int |
63
|
|
|
{ |
64
|
12 |
|
return $this->time; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @inheritDoc |
70
|
|
|
*/ |
71
|
6 |
|
public function count() |
72
|
|
|
{ |
73
|
6 |
|
return $this->getExposures()->count(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @inheritDoc |
80
|
|
|
*/ |
81
|
6 |
|
public function getIterator() |
82
|
|
|
{ |
83
|
6 |
|
$data = $this->getData(); |
84
|
6 |
|
return new \ArrayIterator( $data ); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @inheritDoc |
90
|
|
|
* @return Exposures |
91
|
|
|
*/ |
92
|
48 |
|
public function getExposures(): ExposuresInterface { |
93
|
48 |
|
return $this->exposures; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @param ExposuresProviderInterface|float[] $exposures [description] |
99
|
|
|
* @return $this Fluent interface |
100
|
|
|
*/ |
101
|
48 |
|
protected function setExposures( $exposures ) |
102
|
|
|
{ |
103
|
48 |
|
if (is_array($exposures)) |
104
|
9 |
|
$exposures = new Exposures($exposures); |
105
|
|
|
|
106
|
48 |
|
if (!$exposures instanceOf ExposuresProviderInterface) |
107
|
|
|
throw new FilmToolsInvalidArgumentException("Array or ExposuresProviderInterface expected"); |
108
|
|
|
|
109
|
48 |
|
$this->exposures = $exposures->getExposures(); |
110
|
48 |
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @inheritDoc |
116
|
|
|
* @return Densities |
117
|
|
|
*/ |
118
|
48 |
|
public function getDensities(): DensitiesInterface { |
119
|
48 |
|
return $this->densities; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param DensitiesProviderInterface|float[] $exposures [description] |
|
|
|
|
125
|
|
|
* @return $this Fluent interface |
126
|
|
|
*/ |
127
|
48 |
|
protected function setDensities( $densities ) |
128
|
|
|
{ |
129
|
48 |
|
if (is_array($densities)) |
130
|
9 |
|
$densities = new Densities($densities); |
131
|
|
|
|
132
|
48 |
|
if (!$densities instanceOf DensitiesProviderInterface) |
133
|
|
|
throw new FilmToolsInvalidArgumentException("Array or DensitiesProviderInterface expected"); |
134
|
|
|
|
135
|
48 |
|
$this->densities = $densities->getDensities(); |
136
|
48 |
|
return $this; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Checks if a given logH exposure exists in this developing run. |
142
|
|
|
* |
143
|
|
|
* @inheritDoc |
144
|
|
|
*/ |
145
|
3 |
|
public function has( $logH ) |
146
|
|
|
{ |
147
|
3 |
|
$result = $this->getExposures()->search($logH); |
148
|
3 |
|
return !is_null($result) and ($result !== false); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Returns the density value for a given logH exposure. |
154
|
|
|
* |
155
|
|
|
* @inheritDoc |
156
|
|
|
* @return float |
157
|
|
|
*/ |
158
|
3 |
|
public function get( $logH ): float |
159
|
|
|
{ |
160
|
3 |
|
if (!$this->has($logH)): |
161
|
3 |
|
$msg = sprintf("No data for logH exposure '%s'", $logH); |
162
|
3 |
|
throw new ExposureNotFoundException( $msg ); |
163
|
|
|
endif; |
164
|
3 |
|
$index = $this->getExposures()->search( $logH ); |
165
|
3 |
|
return $this->getDensities()->offsetGet( $index ); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @inheritDoc |
171
|
|
|
*/ |
172
|
12 |
|
public function getData() : array |
173
|
|
|
{ |
174
|
12 |
|
return $this->data; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
|
178
|
42 |
|
protected function resetData() |
179
|
|
|
{ |
180
|
|
|
$exposures = array_map(function($e) { return "" . $e; }, $this->getExposures()->getArrayCopy()); |
181
|
|
|
|
182
|
42 |
|
$this->data = array_combine( |
183
|
42 |
|
$exposures, |
184
|
42 |
|
$this->getDensities()->getArrayCopy() |
185
|
|
|
); |
186
|
42 |
|
} |
187
|
|
|
} |
188
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.