/** * @param $apiToken * @param \GuzzleHttp\ClientInterface|null $client * * @return HttpClient */ public static function forToken($apiToken, ClientInterface $client = null) { if (!$client) { $client = new Client(['base_uri' => \RightSignature::API_ENDPOINT]); } $instance = new self($client); $instance->setToken($apiToken); return $instance; }
/** * @param \SimpleXMLElement $xmlElement * @return Token */ public static function parseFromXml(\SimpleXMLElement $xmlElement) { $token = new self(); if (!empty($xmlElement->token)) { $token->setToken((string) $xmlElement->token); } if (!empty($xmlElement->tokenSecret)) { $token->setTokenSecret((string) $xmlElement->tokenSecret); } if (!empty($xmlElement->user)) { $userObject = User::parseFromXml($xmlElement->user); $token->setUser($userObject); } if (!empty($xmlElement->consumer)) { $consumerObject = Consumer::parseFromXml($xmlElement->consumer); $token->setConsumer($consumerObject); } return $token; }
/** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge(['provider' => null, 'token' => null], $values); $message->setProvider($values['provider']); $message->setToken($values['token']); return $message; }
/** * Loads a Profiler for the given token. * * @param string $token A token * * @return Profiler A new Profiler instance */ public function loadFromToken($token) { $profiler = new self($this->storage, $this->logger); $profiler->setToken($token); return $profiler; }
/** * @return a client object */ public static function getInstance($token = NULL) { $instance = new self(); $instance->setToken($token); return $instance; }
/** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge(['token' => null, 'expiration_time' => null, 'iv' => null], $values); $message->setToken($values['token']); $message->setExpirationTime($values['expiration_time']); $message->setIv($values['iv']); return $message; }
public static function create(array $data, $self = null) { if ($self == null) { $self = new self(); } if (isset($data['id'])) { $self->setId($data['id']); } if (isset($data['token'])) { $self->setToken($data['token']); } if (isset($data['refresh_token'])) { $self->setRefreshToken($data['refresh_token']); } if (isset($data['grant_type'])) { $self->setGrantType($data['grant_type']); } if (isset($data['status'])) { $self->setStatus($data['status']); } if (isset($data['expires'])) { $self->setExpires($data['expires']); } return $self; }
/** * @param \DOMElement $element * * @throws \InvalidArgumentException * @return self * * @todo define exception message */ public static function fromXml(\DOMElement $element) { $xpath = new \DOMXPath($element->ownerDocument); $xpath->registerNamespace('D', 'DAV:'); $xLockType = $xpath->query('D:locktype/*', $element); $xLockScope = $xpath->query('D:lockscope/*', $element); if ($xLockType->length == 0 || $xLockScope->length == 0) { throw new \InvalidArgumentException(); } $result = new self($xLockScope->item(0)->localName, $xLockType->item(0)->localName); if ($depth = $xpath->evaluate('string(D:depth)', $element)) { $result->setDepth(DepthHeader::parse($depth)); } if ($timeout = $xpath->evaluate('string(D:timeout)', $element)) { $result->setTimeout($timeout); } $xOwner = $xpath->query('D:owner', $element); if ($xOwner->length) { $result->setOwner(trim($xOwner->item(0)->textContent)); } $xLockToken = $xpath->query('D:locktoken', $element); if ($xLockToken->length) { $result->setToken(trim($xLockToken->item(0)->textContent)); } return $result; }