Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
Rectangle | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
left | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
top | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
right | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
bottom | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
__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 | |
10 | /** |
11 | * 矩形領域。 |
12 | */ |
13 | readonly class Rectangle implements Stringable |
14 | { |
15 | /** |
16 | * 生成。 |
17 | * |
18 | * @param Point $point 開始座標。 |
19 | * @param Size $size 開始座標からの幅と高さ。 |
20 | */ |
21 | public function __construct( |
22 | public Point $point, |
23 | public Size $size |
24 | ) { |
25 | } |
26 | |
27 | #region function |
28 | |
29 | public function left(): int |
30 | { |
31 | return $this->point->x; |
32 | } |
33 | public function top(): int |
34 | { |
35 | return $this->point->y; |
36 | } |
37 | |
38 | public function right(): int |
39 | { |
40 | return $this->point->x + $this->size->width; |
41 | } |
42 | public function bottom(): int |
43 | { |
44 | return $this->point->y + $this->size->height; |
45 | } |
46 | |
47 | #endregion |
48 | |
49 | #region Stringable |
50 | |
51 | public function __toString(): string |
52 | { |
53 | return Code::toString($this, ['point', 'size']); |
54 | } |
55 | |
56 | #endregion |
57 | } |