hasExtension() 공개 정적인 메소드

Returns whether the path has an extension.
부터: 1.1 Added method.
부터: 2.0 Method now fails if $path or $extensions have invalid types.
public static hasExtension ( string $path, string | array | null $extensions = null, boolean $ignoreCase = false ) : boolean
$path string The path string.
$extensions string | array | null If null or not provided, checks if an extension exists, otherwise checks for the specified extension or array of extensions (with or without leading dot).
$ignoreCase boolean Whether to ignore case-sensitivity (requires mbstring extension for correct multi-byte character handling in the extension).
리턴 boolean Returns `true` if the path has an (or the specified) extension and `false` otherwise.
예제 #1
0
 /**
  * Creates a new runner.
  *
  * @param string|null $binDir The path to Composer's "bin-dir".
  */
 public function __construct($binDir = null)
 {
     $phpFinder = new PhpExecutableFinder();
     if (!($php = $phpFinder->find())) {
         throw new RuntimeException('The "php" command could not be found.');
     }
     $puliFinder = new ExecutableFinder();
     // Search:
     // 1. in the current working directory
     // 2. in Composer's "bin-dir"
     // 3. in the system path
     $searchPath = array_merge(array(getcwd()), (array) $binDir);
     // Search "puli.phar" in the PATH and the current directory
     if (!($puli = $puliFinder->find('puli.phar', null, $searchPath))) {
         // Search "puli" in the PATH and Composer's "bin-dir"
         if (!($puli = $puliFinder->find('puli', null, $searchPath))) {
             throw new RuntimeException('The "puli"/"puli.phar" command could not be found.');
         }
     }
     if (Path::hasExtension($puli, '.bat', true)) {
         $this->puli = $puli;
     } else {
         $this->puli = $php . ' ' . $puli;
     }
 }
예제 #2
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The extensions must be strings. Got: stdClass
  */
 public function testHasExtensionFailsIfInvalidExtension()
 {
     Path::hasExtension('/style.css', (object) array());
 }