Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12694 anikendra 1
<?php
2
/**
3
 * OAuth2 Token
4
 *
5
 * @package    OAuth2
6
 * @category   Token
7
 * @author     Phil Sturgeon
8
 * @copyright  (c) 2011 HappyNinjas Ltd
9
 */
10
 
11
abstract class OAuth2_Token {
12
 
13
	/**
14
	 * Create a new token object.
15
	 *
16
	 *     $token = OAuth2_Token::factory($name);
17
	 *
18
	 * @param   string  token type
19
	 * @param   array   token options
20
	 * @return  Token
21
	 */
22
	public static function factory($name = 'access', array $options = null)
23
	{
24
		$name = ucfirst(strtolower($name));
25
 
26
		include_once 'Token/'.$name.'.php';
27
 
28
		$class = 'OAuth2_Token_'.$name;
29
 
30
		return new $class($options);
31
	}
32
 
33
	/**
34
	 * Return the value of any protected class variable.
35
	 *
36
	 *     // Get the token secret
37
	 *     $secret = $token->secret;
38
	 *
39
	 * @param   string  variable name
40
	 * @return  mixed
41
	 */
42
	public function __get($key)
43
	{
44
		return $this->$key;
45
	}
46
 
47
	/**
48
	 * Return a boolean if the property is set
49
	 *
50
	 *     // Get the token secret
51
	 *     if ($token->secret) exit('YAY SECRET');
52
	 *
53
	 * @param   string  variable name
54
	 * @return  bool
55
	 */
56
	public function __isset($key)
57
	{
58
		return isset($this->$key);
59
	}
60
 
61
} // End Token