Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getDistance(int $point1 = null, int $point2 = null)
- {
- $message = "В аргументах указаны несуществующие точки";
- try {
- if (isset($this->points[$point1]) && isset($this->points[$point2])) {
- $p1 = $this->points[$point1];
- $p2 = $this->points[$point2];
- return sqrt((float) (pow(($p2[0] - $p1[0]), 2) + pow(($p2[1] - $p1[1]), 2)));
- }
- }
- catch (\ArgumentCountError $exception) {
- // Здесь можно логировать ошибку.
- }
- return $message;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement