Assert\Assertion::file PHP Method

file() public static method

Assert that a file exists
public static file ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$message string | null
$propertyPath string | null
return boolean
    public static function file($value, $message = null, $propertyPath = null)
    {
        static::string($value, $message, $propertyPath);
        static::notEmpty($value, $message, $propertyPath);
        if (!is_file($value)) {
            $message = sprintf($message ?: 'File "%s" was expected to exist.', static::stringify($value));
            throw static::createException($value, $message, static::INVALID_FILE, $propertyPath);
        }
        return true;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * It should be instantiated with the title of
  * the workshop and the path to the DI configuration file.
  *
  * @param string $workshopTitle The workshop title - this is used throughout the application
  * @param string $diConfigFile The absolute path to the DI configuration file
  */
 public function __construct($workshopTitle, $diConfigFile)
 {
     Assertion::string($workshopTitle);
     Assertion::file($diConfigFile);
     $this->workshopTitle = $workshopTitle;
     $this->diConfigFile = $diConfigFile;
 }
All Usage Examples Of Assert\Assertion::file