SHOW:
|
|
- or go back to the newest paste.
1 | public function getDistance(int $point1 = null, int $point2 = null) | |
2 | { | |
3 | $message = "В аргументах указаны несуществующие точки"; | |
4 | ||
5 | try { | |
6 | if (isset($this->points[$point1]) && isset($this->points[$point2])) { | |
7 | $p1 = $this->points[$point1]; | |
8 | $p2 = $this->points[$point2]; | |
9 | ||
10 | - | return sqrt((float) (pow(($p2[0] - $p1[0]), 2) + pow(($p2[1] - $p1[1]), 2))); |
10 | + | return sqrt((float) ( |
11 | pow(($p2[0] - $p1[0]), 2) + | |
12 | pow(($p2[1] - $p1[1]), 2) | |
13 | )); | |
14 | } | |
15 | } | |
16 | catch (\ArgumentCountError $exception) { | |
17 | // Здесь можно логировать ошибку. | |
18 | } | |
19 | ||
20 | return $message; | |
21 | } |