Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)));
  11.         }
  12.     }
  13.     catch (\ArgumentCountError $exception) {
  14.         // Здесь можно логировать ошибку.
  15.     }
  16.    
  17.     return $message;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement