DmitryDulepov\Realurl\Encoder\UrlEncoder::checkForAllEmptySegments PHP Method

checkForAllEmptySegments() protected method

Checks if all segments are empty and makes the empty array in such case.
protected checkForAllEmptySegments ( array &$segments ) : void
$segments array
return void
    protected function checkForAllEmptySegments(&$segments)
    {
        // If all segments are empty, do not set them. No, array_filter() is not a better solution!
        if (count($segments) > 0) {
            $allSegmentsAreEmpty = TRUE;
            foreach ($segments as $segment) {
                if ($segment) {
                    $allSegmentsAreEmpty = FALSE;
                    break;
                }
            }
            if ($allSegmentsAreEmpty) {
                $segments = array();
            }
        }
    }