Commando\Option::setFileRequirements PHP Method

setFileRequirements() public method

Require that the argument is a file. This will make sure the argument is a valid file, will expand the file path provided to a full path (e.g. map relative paths), and in the case where $allow_globbing is set, supports file globbing and returns an array of matching files.
public setFileRequirements ( boolean $require_exists = true, boolean $allow_globbing = true ) : void
$require_exists boolean
$allow_globbing boolean
return void
    public function setFileRequirements($require_exists = true, $allow_globbing = true)
    {
        $this->file = true;
        $this->file_require_exists = $require_exists;
        $this->file_allow_globbing = $allow_globbing;
    }

Usage Example

 public function testFileGlob()
 {
     $file = dirname(__FILE__) . '/assets/*.txt';
     $option = new Option(0);
     $option->setFileRequirements(true, true);
     $option->setValue($file);
     $file1 = dirname(__FILE__) . '/assets/example.txt';
     $file2 = dirname(__FILE__) . '/assets/another.txt';
     $values = $option->getValue();
     $this->assertTrue($option->isFile());
     $this->assertCount(2, $values);
     $this->assertTrue(in_array($file1, $values));
     $this->assertTrue(in_array($file2, $values));
 }