@@ -85,6 +85,62 @@ public function testFindInt($data, $key, $default, $expected): void
8585 $ this ->assertSame ($ expected , $ reader ->findInt ($ key , $ default ));
8686 }
8787
88+ /**
89+ * Test.
90+ *
91+ * @dataProvider providerGetFloat
92+ *
93+ * @param mixed $data The data
94+ * @param string|key $key The lookup key
95+ * @param mixed $default The default value
96+ * @param mixed $expected The expected value
97+ *
98+ * @return void
99+ */
100+ public function testGetFloat ($ data , $ key , $ default , $ expected ): void
101+ {
102+ $ reader = new ArrayReader ($ data );
103+ $ this ->assertSame ($ expected , $ reader ->getFloat ($ key , $ default ));
104+ }
105+
106+ /**
107+ * Test.
108+ *
109+ * @dataProvider providerGetFloatError
110+ *
111+ * @param mixed $data The data
112+ * @param string|int $key The lookup key
113+ * @param mixed $default The default value
114+ *
115+ * @return void
116+ */
117+ public function testGetFloatError ($ data , $ key , $ default ): void
118+ {
119+ $ reader = new ArrayReader ($ data );
120+
121+ $ this ->expectException (InvalidArgumentException::class);
122+
123+ $ reader ->getFloat ($ key , $ default );
124+ }
125+
126+ /**
127+ * Test.
128+ *
129+ * @dataProvider providerFindFloat
130+ *
131+ * @param mixed $data The data
132+ * @param string|int $key The lookup key
133+ * @param mixed $default The default value
134+ * @param mixed $expected The expected value
135+ *
136+ * @return void
137+ */
138+ public function testFindFloat ($ data , $ key , $ default , $ expected ): void
139+ {
140+ $ reader = new ArrayReader ($ data );
141+ $ this ->assertSame ($ expected , $ reader ->findFloat ($ key , $ default ));
142+ }
143+
88144 /**
89145 * Provider.
90146 *
@@ -132,6 +188,53 @@ public function providerFindInt(): array
132188 ];
133189 }
134190
191+ /**
192+ * Provider.
193+ *
194+ * @return array[] The test data
195+ */
196+ public function providerGetFloat (): array
197+ {
198+ return [
199+ [[0.1 , 1.2 , 2.3 , 3.4 ], 0 , null , 0.1 ],
200+ [[0.1 , 1.2 , 2.3 , 3.4 ], 1 , null , 1.2 ],
201+ [[0.1 , 1.2 , 2.3 , 3.4 ], 2 , null , 2.3 ],
202+ [[0.1 , 1.2 , 2.3 , 3.4 ], 3 , null , 3.4 ],
203+ ];
204+ }
205+
206+ /**
207+ * Provider.
208+ *
209+ * @return array[] The test data
210+ */
211+ public function providerGetFloatError (): array
212+ {
213+ return [
214+ [[0.1 , 1.2 , 2.3 , 3.4 ], 4 , null ],
215+ [[0.1 , 1.2 , 2.3 , 3.4 , null ], 4 , null ],
216+ [[0.1 , 1.2 , 2.3 , null , 4.4 ], 3 , null ],
217+ ];
218+ }
219+
220+ /**
221+ * Provider.
222+ *
223+ * @return array[] The test data
224+ */
225+ public function providerFindFloat (): array
226+ {
227+ return [
228+ [[0.1 , 1.2 , 2.3 , 3.4 ], 0 , null , 0.1 ],
229+ [[0.1 , 1.2 , 2.3 , 3.4 ], 1 , null , 1.2 ],
230+ [[0.1 , 1.2 , 2.3 , 3.4 ], 2 , null , 2.3 ],
231+ [[0.1 , 1.2 , 2.3 , 3.4 ], 3 , null , 3.4 ],
232+ [[0.1 , 1.2 , 2.3 , 3.4 ], 4 , null , null ],
233+ [[0.1 , 1.2 , 2.3 , 3.4 , null ], 4 , null , null ],
234+ [[0.1 , 1.2 , 2.3 , null , 4.4 ], 3 , null , null ],
235+ ];
236+ }
237+
135238 /**
136239 * Test.
137240 *
0 commit comments