1 | <?php |
||
12 | class Point implements IEqualable |
||
|
|||
13 | { |
||
14 | private $x; |
||
15 | private $y; |
||
16 | |||
17 | |||
18 | /** |
||
19 | * Creates a new point from its X- and Y-coordinates, either specified as two arguments or as a two-item array. |
||
20 | * |
||
21 | * @param float|float[] $x |
||
22 | * @param float|null $y |
||
23 | * @return Point |
||
24 | */ |
||
25 | public static function fromCoords($x, $y = null): Point |
||
41 | |||
42 | |||
43 | private function __construct(float $x, float $y) |
||
48 | |||
49 | /** |
||
50 | * @return float the X-coordinate of the point |
||
51 | */ |
||
52 | public function getX(): float |
||
56 | |||
57 | /** |
||
58 | * @return float the Y-coordinate of the point |
||
59 | */ |
||
60 | public function getY(): float |
||
64 | |||
65 | /** |
||
66 | * @return float[] pair of the X- and Y-coordinate of the point |
||
67 | */ |
||
68 | public function toCoords(): array |
||
72 | |||
73 | public function __toString() |
||
77 | |||
78 | /** |
||
79 | * @param object $object |
||
80 | * @return bool|null <tt>true</tt> if <tt>$this</tt> and the other <tt>$object</tt> are equal to each other, |
||
81 | * <tt>false</tt> if they are not equal, |
||
82 | * <tt>null</tt> iff <tt>$object</tt> is <tt>null</tt> |
||
83 | */ |
||
84 | public function equals($object): ?bool |
||
98 | } |
||
99 |