original_string: protected function splitPathToSegments($path)
      {
          $path = MediaLibrary::validatePath($path, true);
          $path = explode('/', ltrim($path, '/'));
  
          $result = [];
          while (count($path) > 0) {
              $folder = array_pop($path);
  
              $result[$folder] = implode('/', $path).'/'.$folder;
              if (substr($result[$folder], 0, 1) != '/') {
                  $result[$folder] = '/'.$result[$folder];
              }
          }
  
          return array_reverse($result, true);
      }
code: protected function splitPathToSegments($path)
      {
          $path = MediaLibrary::validatePath($path, true);
          $path = explode('/', ltrim($path, '/'));
  
          $result = [];
          while (count($path) > 0) {
              $folder = array_pop($path);
  
              $result[$folder] = implode('/', $path).'/'.$folder;
              if (substr($result[$folder], 0, 1) != '/') {
                  $result[$folder] = '/'.$result[$folder];
              }
          }
  
          return array_reverse($result, true);
      }
code_tokens: protected function splitPathToSegments ( $ path ) { $ path = MediaLibrary :: validatePath ( $ path , true ) ; $ path = explode ( '/' , ltrim ( $ path , '/' ) ) ; $ result = [ ] ; while ( count ( $ path ) > 0 ) { $ folder = array_pop ( $ path ) ; $ result [ $ folder ] = implode ( '/' , $ path ) . '/' . $ folder ; if ( substr ( $ result [ $ folder ] , 0 , 1 ) != '/' ) { $ result [ $ folder ] = '/' . $ result [ $ folder ] ; } } return array_reverse ( $ result , true ) ; }
docstring: Splits a path in to segments
  @param string $path
  @return array
docstring_tokens: Splits a path in to segments