Newscoop\Storage::createFile PHP Method

createFile() public method

Create file
public createFile ( string $key ) : void
$key string
return void
    public function createFile($key)
    {
        $path = $this->getPath($key);
        if (realpath($path) || !touch($path)) {
            throw new \InvalidArgumentException($key);
        }
    }

Usage Example

Example #1
0
 /**
  * Create file
  *
  * @param string $name
  * @return void
  * @throws InvalidArgumentException
  */
 public function createFile($name)
 {
     try {
         $this->storage->createFile($name);
     } catch (\InvalidArgumentException $e) {
         throw new \InvalidArgumentException(sprintf('A file or folder having the name %s already exists', $name), $e->getCode(), $e);
     }
 }