Beispiel #1
0
 public static function createForManifest(Manifest $manifest, string $pathToZip) : Zip
 {
     $zip = new static($pathToZip);
     $zip->open();
     foreach ($manifest->files() as $file) {
         $zip->add($file, self::determineNameOfFileInZip($file, $pathToZip));
     }
     $zip->close();
     return $zip;
 }
Beispiel #2
0
 public static function get($url, $headers = array())
 {
     $session = new static();
     $options = array(CURLOPT_URL => $url, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true);
     if (count($headers)) {
         $options[CURLOPT_HTTPHEADER] = $headers;
     }
     $session->set_options($options);
     $response = $session->send();
     $session->close();
     return $response;
 }
Beispiel #3
0
 /**
  * Create a channel from the elements within the given array.
  * 
  * @param array $data Data elements, keys will be discarded.
  * @param bool $close Create the channel in closed state?
  */
 public static function fromArray(array $data, bool $close = true) : Channel
 {
     $channel = new static(\count($data));
     foreach ($data as $val) {
         $channel->buffer->enqueue($val);
     }
     if ($close) {
         $channel->close();
     }
     return $channel;
 }
Beispiel #4
0
 /**
  * Write to a file
  *
  * @param string $strFile    Relative file name
  * @param string $strContent Content to be written
  */
 public static function putContent($strFile, $strContent)
 {
     $objFile = new static($strFile, true);
     $objFile->write($strContent);
     $objFile->close();
 }