Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
50.00% |
3 / 6 |
|
50.00% |
3 / 6 |
CRAP | |
0.00% |
0 / 1 |
ImageSetting | |
50.00% |
3 / 6 |
|
50.00% |
3 / 6 |
10.50 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
options | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
png | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
jpeg | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
webp | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
bmp | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\Core\Image; |
6 | |
7 | use PeServer\Core\Image\ImageType; |
8 | |
9 | /** |
10 | * 画像生成設定。 |
11 | */ |
12 | readonly class ImageSetting |
13 | { |
14 | /** |
15 | * 生成。 |
16 | * |
17 | * @param ImageType $imageType |
18 | * @param mixed[] $options イメージ生成処理用オプション。 |
19 | */ |
20 | public function __construct( |
21 | public ImageType $imageType, |
22 | protected array $options |
23 | ) { |
24 | } |
25 | |
26 | #region function |
27 | |
28 | /** |
29 | * オプション。 |
30 | * |
31 | * @return mixed[] |
32 | */ |
33 | public function options(): array |
34 | { |
35 | return $this->options; |
36 | } |
37 | |
38 | public static function png(int $quality = -1, int $filters = -1): self |
39 | { |
40 | return new self(ImageType::Png, [$quality, $filters]); |
41 | } |
42 | |
43 | public static function jpeg(int $quality = -1): self |
44 | { |
45 | return new self(ImageType::Jpeg, [$quality]); |
46 | } |
47 | |
48 | public static function webp(int $quality = -1): self |
49 | { |
50 | return new self(ImageType::Webp, [$quality]); |
51 | } |
52 | |
53 | public static function bmp(bool $compressed = true): self |
54 | { |
55 | return new self(ImageType::Bmp, [$compressed]); |
56 | } |
57 | |
58 | #endregion |
59 | } |