protected function buildDirectionsLeg(\stdClass $directionsLeg)
    {
        $distance = new Distance($directionsLeg->distance->text, $directionsLeg->distance->value);
        $duration = new Duration($directionsLeg->duration->text, $directionsLeg->duration->value);
        $endAddress = $directionsLeg->end_address;
        $endLocation = new Coordinate($directionsLeg->end_location->lat, $directionsLeg->end_location->lng);
        $startAddress = $directionsLeg->start_address;
        $startLocation = new Coordinate($directionsLeg->start_location->lat, $directionsLeg->start_location->lng);
        $steps = $this->buildDirectionsSteps($directionsLeg->steps);

        // The via_waypoint property can not be defined in the xml format.
        if (!isset($directionsLeg->via_waypoint)) {
            $directionsLeg->via_waypoint = array();
        }

        $viaWaypoint = $directionsLeg->via_waypoint;

        return new DirectionsLeg(
            $distance,
            $duration,
            $endAddress,
            $endLocation,
            $startAddress,
            $startLocation,
            $steps,
            $viaWaypoint
        );
    }
protected function buildDirectionsLeg(\stdClass $directionsLeg)
    {
        $distance = new Distance($directionsLeg->distance->text, $directionsLeg->distance->value);
        $duration = new Duration($directionsLeg->duration->text, $directionsLeg->duration->value);
        $endAddress = $directionsLeg->end_address;
        $endLocation = new Coordinate($directionsLeg->end_location->lat, $directionsLeg->end_location->lng);
        $startAddress = $directionsLeg->start_address;
        $startLocation = new Coordinate($directionsLeg->start_location->lat, $directionsLeg->start_location->lng);
        $steps = $this->buildDirectionsSteps($directionsLeg->steps);

        // The via_waypoint property can not be defined in the xml format.
        if (!isset($directionsLeg->via_waypoint)) {
            $directionsLeg->via_waypoint = array();
        }

        $viaWaypoint = $directionsLeg->via_waypoint;

        return new DirectionsLeg(
            $distance,
            $duration,
            $endAddress,
            $endLocation,
            $startAddress,
            $startLocation,
            $steps,
            $viaWaypoint
        );
    }
protected function buildDirectionsLeg ( \ stdClass $ directionsLeg ) { $ distance = new Distance ( $ directionsLeg -> distance -> text , $ directionsLeg -> distance -> value ) ; $ duration = new Duration ( $ directionsLeg -> duration -> text , $ directionsLeg -> duration -> value ) ; $ endAddress = $ directionsLeg -> end_address ; $ endLocation = new Coordinate ( $ directionsLeg -> end_location -> lat , $ directionsLeg -> end_location -> lng ) ; $ startAddress = $ directionsLeg -> start_address ; $ startLocation = new Coordinate ( $ directionsLeg -> start_location -> lat , $ directionsLeg -> start_location -> lng ) ; $ steps = $ this -> buildDirectionsSteps ( $ directionsLeg -> steps ) ; // The via_waypoint property can not be defined in the xml format. if ( ! isset ( $ directionsLeg -> via_waypoint ) ) { $ directionsLeg -> via_waypoint = array ( ) ; } $ viaWaypoint = $ directionsLeg -> via_waypoint ; return new DirectionsLeg ( $ distance , $ duration , $ endAddress , $ endLocation , $ startAddress , $ startLocation , $ steps , $ viaWaypoint ) ; }
Buildd the directions leg according to the normalized directions API leg.

@param \stdClass $directionsLeg The normalized directions leg.

@return \Ivory\GoogleMap\Services\Directions\DirectionsLeg The builded directions leg.
Buildd the directions leg according to the normalized directions API leg .