writeable() public static method

Assert that the value is something writeable
public static writeable ( string $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value string
$message string | null
$propertyPath string | null
return boolean
Exemplo n.º 1
0
 /**
  * @param string $filename
  */
 public function setFilename($filename)
 {
     Assertion::string($filename, 'Invalid filename.');
     Assertion::directory(dirname($filename), 'The selected directory does not exist.');
     Assertion::writeable(dirname($filename), 'The selected directory is not writable.');
     $this->filename = $filename;
 }
 /**
  * @return string
  */
 public function save(\PHPExcel $excel, $id)
 {
     Assertion::notEmpty($id);
     Assertion::string($id);
     Assertion::writeable($this->directory);
     $filePath = $this->directory . $id;
     $pathinfo = pathinfo($id);
     if (!isset($pathinfo['extension'])) {
         throw new \RuntimeException("Extension was expected for report id: '{$id}'. Unable to determine excel type.");
     }
     $writerType = self::extensionToType($pathinfo['extension']);
     $excelWriter = \PHPExcel_IOFactory::createWriter($excel, $writerType);
     $excelWriter->save($filePath);
     return $filePath;
 }
Exemplo n.º 3
0
 public function testWriteable()
 {
     Assertion::writeable(sys_get_temp_dir());
     $this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INVALID_WRITEABLE);
     Assertion::writeable(__DIR__ . '/does-not-exist');
 }