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