src/Maths/Geometry/AbstractGeometricObject.php
public function getSegment($name1, $name2 = null)
    {
        if (is_null($name2)) {
            $points = str_split($name1);
            if (count($points)==2) {
                foreach ($points as $i=>$_p) {
                    if (in_array(strtolower($_p), self::$_magic_points_mapping)) {
                        if ($i==0) {
                            $name1 = $_p;
                        } else {
                            $name2 = $_p;
                        }
                    } else {
                        throw new \InvalidArgumentException(
                            sprintf("Unknown segment '%s'", $name1)
                        );
                    }
                }
            } else {
                throw new \InvalidArgumentException(
                    sprintf("A segment must be a two points representation (got '%s')", $name1)
                );
            }
        }
        $p1 = $this->getPoint($name1);
        $p2 = $this->getPoint($name2);
        if (!is_null($p1) && !is_null($p2)) {
            return new Segment($p1, $p2);
        } else {
            throw new \InvalidArgumentException(
                sprintf("Unknown or undefined point name '%s'", (is_null($p1) ? $point1 : $point2))
            );
        }
    }
public function getSegment($name1, $name2 = null)
    {
        if (is_null($name2)) {
            $points = str_split($name1);
            if (count($points)==2) {
                foreach ($points as $i=>$_p) {
                    if (in_array(strtolower($_p), self::$_magic_points_mapping)) {
                        if ($i==0) {
                            $name1 = $_p;
                        } else {
                            $name2 = $_p;
                        }
                    } else {
                        throw new \InvalidArgumentException(
                            sprintf("Unknown segment '%s'", $name1)
                        );
                    }
                }
            } else {
                throw new \InvalidArgumentException(
                    sprintf("A segment must be a two points representation (got '%s')", $name1)
                );
            }
        }
        $p1 = $this->getPoint($name1);
        $p2 = $this->getPoint($name2);
        if (!is_null($p1) && !is_null($p2)) {
            return new Segment($p1, $p2);
        } else {
            throw new \InvalidArgumentException(
                sprintf("Unknown or undefined point name '%s'", (is_null($p1) ? $point1 : $point2))
            );
        }
    }
Get a [point1->point2] segment as a `\Maths\Geometry\Segment` object

You can equally use `$obj->getSegment(a,b)` or `$obj->getSegment(ab)`

@param   string          $name1 name of first point of the segment
@param   string|null     $name2 name of first point of the segment
@return  Segment
@throws  \InvalidArgumentException if the segmentation can't be constructed (wrong parameters)
@throws  \InvalidArgumentException if `$name1` is more than 2 chars length
@throws  \InvalidArgumentException if one of the points is not found