|
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
|
30 |
|
public function __construct( $exposures, $densities, int $time) |
|
43
|
|
|
{ |
|
44
|
30 |
|
$this->setExposures( $exposures ); |
|
45
|
30 |
|
$this->setDensities( $densities ); |
|
46
|
|
|
|
|
47
|
30 |
|
if (count($this->getExposures()) != count( $this->getDensities() )) |
|
48
|
6 |
|
throw new DataLengthMismatchException; |
|
49
|
|
|
|
|
50
|
24 |
|
$this->resetData(); |
|
51
|
|
|
|
|
52
|
24 |
|
$this->time = $time; |
|
53
|
24 |
|
} |
|
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
|
30 |
|
public function getExposures(): ExposuresInterface { |
|
93
|
30 |
|
return $this->exposures; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @param ExposuresProviderInterface|float[] $exposures [description] |
|
99
|
|
|
* @return $this Fluent interface |
|
100
|
|
|
*/ |
|
101
|
30 |
|
protected function setExposures( $exposures ) |
|
102
|
|
|
{ |
|
103
|
30 |
|
if (is_array($exposures)) |
|
104
|
12 |
|
$exposures = new Exposures($exposures); |
|
105
|
|
|
|
|
106
|
30 |
|
if (!$exposures instanceOf ExposuresProviderInterface) |
|
107
|
|
|
throw new FilmToolsInvalidArgumentException("Array or ExposuresProviderInterface expected"); |
|
108
|
|
|
|
|
109
|
30 |
|
$this->exposures = $exposures->getExposures(); |
|
110
|
30 |
|
return $this; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @inheritDoc |
|
116
|
|
|
* @return Densities |
|
117
|
|
|
*/ |
|
118
|
30 |
|
public function getDensities(): DensitiesInterface { |
|
119
|
30 |
|
return $this->densities; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @param DensitiesProviderInterface|float[] $exposures [description] |
|
|
|
|
|
|
125
|
|
|
* @return $this Fluent interface |
|
126
|
|
|
*/ |
|
127
|
30 |
|
protected function setDensities( $densities ) |
|
128
|
|
|
{ |
|
129
|
30 |
|
if (is_array($densities)) |
|
130
|
15 |
|
$densities = new Densities($densities); |
|
131
|
|
|
|
|
132
|
30 |
|
if (!$densities instanceOf DensitiesProviderInterface) |
|
133
|
|
|
throw new FilmToolsInvalidArgumentException("Array or DensitiesProviderInterface expected"); |
|
134
|
|
|
|
|
135
|
30 |
|
$this->densities = $densities->getDensities(); |
|
136
|
30 |
|
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 |
|
return ($this->getExposures()->search($logH) !== false); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* Returns the density value for a given logH exposure. |
|
153
|
|
|
* |
|
154
|
|
|
* @inheritDoc |
|
155
|
|
|
* @return float |
|
156
|
|
|
*/ |
|
157
|
3 |
|
public function get( $logH ): float |
|
158
|
|
|
{ |
|
159
|
3 |
|
$index = $this->getExposures()->search( $logH ); |
|
160
|
|
|
|
|
161
|
3 |
|
if ($index === false ): |
|
162
|
3 |
|
$msg = sprintf("No data for logH exposure '%s'", $logH); |
|
163
|
3 |
|
throw new ExposureNotFoundException( $msg ); |
|
164
|
|
|
endif; |
|
165
|
|
|
|
|
166
|
3 |
|
return $this->getDensities()->offsetGet( $index ); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @inheritDoc |
|
172
|
|
|
*/ |
|
173
|
12 |
|
public function getData() : array |
|
174
|
|
|
{ |
|
175
|
12 |
|
return $this->data; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
|
|
179
|
24 |
|
protected function resetData() |
|
180
|
|
|
{ |
|
181
|
24 |
|
$this->data = array_combine( |
|
182
|
24 |
|
$this->getExposures()->getArrayCopy(), |
|
183
|
24 |
|
$this->getDensities()->getArrayCopy() |
|
184
|
|
|
); |
|
185
|
24 |
|
} |
|
186
|
|
|
} |
|
187
|
|
|
|
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
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.