예제 #1
0
파일: Path.php 프로젝트: brainsware/sauce
 public static function join()
 {
     $args = func_get_args();
     if (empty($args)) {
         return '';
     }
     $paths = new Vector();
     foreach ($args as $arg) {
         if (is_string($arg)) {
             $arg = explode(self::delimiter, $arg);
         }
         if (is_an_array($arg)) {
             foreach ($arg as $fragment) {
                 $paths->push($fragment);
             }
             continue;
         }
         $paths->push($arg);
     }
     $paths = $paths->select(function ($path) {
         $str = strval($path);
         return !empty($str);
     });
     $joined_path = $paths->join(self::delimiter);
     if (S($args[0])->starts_with(self::delimiter)) {
         $joined_path->prependF(self::delimiter);
     }
     return $joined_path;
 }