示例#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;
 }