Exemplo n.º 1
0
 /**
  * Create a paste instance from a key and draft.
  * @param string $url The URL of the paste.
  * @param \Brush\Pastes\Draft $draft The draft to import.
  * @return \Brush\Pastes\Paste The created paste.
  */
 public static function fromPasted($url, Draft $draft)
 {
     $paste = new Paste();
     $paste->import($draft);
     $paste->setUrl($url);
     $paste->setDate(time());
     $paste->setHits(0);
     $offset = Expiry::getOffset($draft->getExpiry());
     $paste->setExpires($offset == 0 ? 0 : $paste->getDate() + $offset);
     return $paste;
 }
Exemplo n.º 2
0
 /**
  * Get a plaintext string representation of these defaults.
  * @return string The paste defaults.
  */
 public function __toString()
 {
     $defaults = 'Paste Defaults:' . PHP_EOL;
     $defaults .= "\t" . 'Format: ' . $this->getFormat()->getName() . PHP_EOL;
     $defaults .= "\t" . 'Visibility: ' . Visibility::toString($this->getVisibility()) . PHP_EOL;
     $defaults .= "\t" . 'Expiry: ' . Expiry::toString($this->getExpiry());
     return $defaults;
 }