modifs.mineures sans commentaires
This commit is contained in:
		
							parent
							
								
									32a9239209
								
							
						
					
					
						commit
						fd54686f1d
					
				@ -269,10 +269,23 @@ class path {
 | 
				
			|||||||
    return strpos($file, ".", $pos) !== false;
 | 
					    return strpos($file, ".", $pos) !== false;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static final function ensure_ext(string $path, string $new_ext, ?string $replace_ext=null): string {
 | 
					  /**
 | 
				
			||||||
 | 
					   * @param string $path
 | 
				
			||||||
 | 
					   * @param string $new_ext
 | 
				
			||||||
 | 
					   * @param string|array|null $replace_ext
 | 
				
			||||||
 | 
					   * @return string
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  static final function ensure_ext(string $path, string $new_ext, $replace_ext=null): string {
 | 
				
			||||||
    [$dir, $filename] = self::split($path);
 | 
					    [$dir, $filename] = self::split($path);
 | 
				
			||||||
    if (self::ext($filename) === $replace_ext) {
 | 
					    $ext = self::ext($filename);
 | 
				
			||||||
      $filename = self::basename($filename);
 | 
					    if ($ext !== null && $replace_ext !== null) {
 | 
				
			||||||
 | 
					      if (is_string($replace_ext)) $replace_ext = [$replace_ext];
 | 
				
			||||||
 | 
					      foreach ($replace_ext as $old_ext) {
 | 
				
			||||||
 | 
					        if ($ext === $old_ext) {
 | 
				
			||||||
 | 
					          $filename = self::basename($filename);
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    $filename .= $new_ext;
 | 
					    $filename .= $new_ext;
 | 
				
			||||||
    return self::join($dir, $filename);
 | 
					    return self::join($dir, $filename);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user