/** * Загружает JSON Web Signature * * @param string $jwt JSON Web Signature * @param bool $payload_is_array Данные запроса * @return JWS object */ public static function load($jwt, $payload_is_array = false) { // split 3 parts $part = explode('.', $jwt); if (!is_array($part) || empty($part) || count($part) !== 3) { return false; } $header = self::getHeader($jwt); if ($header && isset($header['alg'])) { $jwtobj = new self($header['alg']); foreach ($header as $key => $value) { $jwtobj->setHeaderItem($key, $value); } $jwtobj->setPayload(self::getPayload($jwt, $payload_is_array)); $jwtobj->setTokenString($jwt); return $jwtobj; } else { return false; } }
/** * factory method for creating a new notification * * @param array $devices * @param $payload * @param $collapseKey * @param $timeToLive * @param $delayWhileIdle * @return Notification */ public static function factory(array $devices, $payload, $collapseKey = null, $timeToLive = null, $delayWhileIdle = false) { $notification = new self(); $notification->setDevices($devices); $notification->setPayload($payload); $notification->setCollapseKey($collapseKey); $notification->setTimeToLive($timeToLive); $notification->setDelayWhileIdle($delayWhileIdle); return $notification; }