示例#1
0
 /**
  * @param string $path
  * @return string
  */
 private function validatePath(string $path) : string
 {
     $path = realpath($path) ?: $path;
     if (!file_exists($path)) {
         throw FileNotExistsException::exceptionForFile($path);
     }
     if (!is_readable($path)) {
         throw FileNotReadableException::exceptionForFile($path);
     }
     return $path;
 }
示例#2
0
 /**
  * @return string
  */
 public function getContents() : string
 {
     if (!$this->contents) {
         if (!file_exists($this->path)) {
             FileNotExistsException::exceptionForFile($this->path);
         }
         if (!is_readable($this->path)) {
             FileNotReadableException::exceptionForFile($this->path);
         }
         $this->contents = file_get_contents($this->path);
     }
     return $this->contents;
 }