Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Size | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
__toString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\Core\Image; |
6 | |
7 | use Stringable; |
8 | use PeServer\Core\Code; |
9 | use PeServer\Core\Throws\ArgumentException; |
10 | |
11 | /** |
12 | * 幅と高さを持つ。 |
13 | */ |
14 | readonly class Size implements Stringable |
15 | { |
16 | /** |
17 | * 生成 |
18 | * |
19 | * @param int $width 横幅。 |
20 | * @phpstan-param positive-int $width |
21 | * @param int $height 高さ。 |
22 | * @phpstan-param positive-int $height |
23 | */ |
24 | public function __construct( |
25 | public int $width, |
26 | public int $height |
27 | ) { |
28 | if ($width < 1) { //@phpstan-ignore-line [DOCTYPE] |
29 | throw new ArgumentException('$width'); |
30 | } |
31 | if ($height < 1) { //@phpstan-ignore-line [DOCTYPE] |
32 | throw new ArgumentException('$height'); |
33 | } |
34 | } |
35 | |
36 | #region Stringable |
37 | |
38 | public function __toString(): string |
39 | { |
40 | return Code::toString($this, ['width', 'height']); |
41 | } |
42 | |
43 | #endregion |
44 | } |