File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
namespace Intervention \Image ;
6
6
7
+ use ArrayIterator ;
7
8
use Intervention \Image \Interfaces \ResolutionInterface ;
9
+ use IteratorAggregate ;
8
10
use Stringable ;
11
+ use Traversable ;
9
12
10
- class Resolution implements ResolutionInterface, Stringable
13
+ /**
14
+ * @implements IteratorAggregate<float>
15
+ */
16
+ class Resolution implements ResolutionInterface, Stringable, IteratorAggregate
11
17
{
12
18
public const PER_INCH = 1 ;
13
19
public const PER_CM = 2 ;
@@ -24,6 +30,17 @@ public function __construct(
24
30
protected float $ y ,
25
31
protected int $ per_unit = self ::PER_INCH
26
32
) {
33
+ //
34
+ }
35
+
36
+ /**
37
+ * {@inheritdoc}
38
+ *
39
+ * @see IteratorAggregate::getIterator()
40
+ */
41
+ public function getIterator (): Traversable
42
+ {
43
+ return new ArrayIterator ([$ this ->x , $ this ->y ]);
27
44
}
28
45
29
46
/**
Original file line number Diff line number Diff line change @@ -17,6 +17,14 @@ public function testConstructor(): void
17
17
$ this ->assertInstanceOf (Resolution::class, $ resolution );
18
18
}
19
19
20
+ public function testIteration (): void
21
+ {
22
+ $ resolution = new Resolution (1.2 , 3.4 );
23
+ foreach ($ resolution as $ value ) {
24
+ $ this ->assertIsFloat ($ value );
25
+ }
26
+ }
27
+
20
28
public function testXY (): void
21
29
{
22
30
$ resolution = new Resolution (1.2 , 3.4 );
You can’t perform that action at this time.
0 commit comments