Beispiel #1
0
<?php

require dirname(__FILE__) . '/../Brush.php';
use Brush\Accounts\Account;
use Brush\Accounts\Developer;
use Brush\Accounts\User;
use Brush\Exceptions\BrushException;
$account = new Account('<user session key>');
$developer = new Developer('<developer key>');
try {
    echo User::fromAccount($account, $developer), PHP_EOL;
} catch (BrushException $e) {
    echo $e->getMessage(), PHP_EOL;
}
Beispiel #2
0
 /**
  * Create a new user from their XML representation.
  * @param \DOMElement $element The user's XML node returned by the Pastebin API.
  * @return \Brush\Accounts\User The created user.
  */
 private static final function fromXml(DOMElement $element)
 {
     $user = new User();
     $user->parse($element);
     return $user;
 }
Beispiel #3
0
 /**
  * Create a new draft with an account's default settings, and set them as the owner.
  * @param \Brush\Accounts\Account $account The owner's account whose settings to use.
  * @param \Brush\Accounts\Developer $developer The developer account to use if settings need to be retrieved.
  * @return \Brush\Pastes\Draft The created draft paste.
  */
 public static function fromOwner(Account $account, Developer $developer)
 {
     $draft = new Draft();
     $draft->setOwner($account);
     User::fromAccount($account, $developer)->getDefaults()->applyTo($draft);
     return $draft;
 }