protected function prepareResponseFormat()
 {
     if ($this->request->hasAttachedVar('format')) {
         Assert::isNotFalse(array_search($this->request->getAttachedVar('format'), $this->allowedFormatList));
     } else {
         $this->request->setAttachedVar('format', self::DEFAULT_FORMAT);
     }
 }
Example #2
0
 public function __construct($nameOrFd, $append = false)
 {
     if (is_resource($nameOrFd)) {
         if (get_resource_type($nameOrFd) !== 'stream') {
             throw new IOException('not a file resource');
         }
         $this->fd = $nameOrFd;
     } else {
         try {
             $this->fd = fopen($nameOrFd, ($append ? 'a' : 'w') . 'b');
             Assert::isNotFalse($this->fd, "File {$nameOrFd} must be exist");
         } catch (BaseException $e) {
             throw new IOException($e->getMessage());
         }
     }
 }