rpicms

A CMS for the Raspberry Pi
git clone git://archive.git.mtrnord.blog/RpicmsTeam/rpicms.git
Log | Files | Refs | README | LICENSE

RefreshToken.php (1608B)


      1 <?php
      2 
      3 /**
      4  *  This program is free software: you can redistribute it and/or modify
      5  *  it under the terms of the GNU Lesser General Public License as published by
      6  *  the Free Software Foundation, either version 3 of the License, or
      7  *  (at your option) any later version.
      8  *
      9  *  This program is distributed in the hope that it will be useful,
     10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  *  GNU Lesser General Public License for more details.
     13  *
     14  *  You should have received a copy of the GNU Lesser General Public License
     15  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16  */
     17 
     18 namespace fkooman\OAuth\Client;
     19 
     20 use fkooman\OAuth\Client\Exception\TokenException;
     21 
     22 class RefreshToken extends Token
     23 {
     24     /** refresh_token VARCHAR(255) NOT NULL */
     25     private $refreshToken;
     26 
     27     public function __construct(array $data)
     28     {
     29         parent::__construct($data);
     30 
     31         foreach (array('refresh_token') as $key) {
     32             if (!array_key_exists($key, $data)) {
     33                 throw new TokenException(sprintf("missing field '%s'", $key));
     34             }
     35         }
     36 
     37         $this->setRefreshToken($data['refresh_token']);
     38     }
     39 
     40     public function setRefreshToken($refreshToken)
     41     {
     42         if (!is_string($refreshToken) || 0 >= strlen($refreshToken)) {
     43             throw new TokenException("refresh_token needs to be a non-empty string");
     44         }
     45         $this->refreshToken = $refreshToken;
     46     }
     47 
     48     public function getRefreshToken()
     49     {
     50         return $this->refreshToken;
     51     }
     52 }