InstagramOAuth   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 65
c 0
b 0
f 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
A getAccessToken() 0 4 1
A setAccessToken() 0 4 1
A isAccessTokenSet() 0 4 1
A getUserInfo() 0 4 1
1
<?php
2
/**
3
 * The MIT License (MIT)
4
 *
5
 * Copyright (c) 2016 Haridarshan Gorana
6
 *
7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
8
 * of this software and associated documentation files (the "Software"), to deal
9
 * in the Software without restriction, including without limitation the rights
10
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
 * copies of the Software, and to permit persons to whom the Software is
12
 * furnished to do so, subject to the following conditions:
13
 *
14
 * The above copyright notice and this permission notice shall be included in all
15
 * copies or substantial portions of the Software.
16
 *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
 * SOFTWARE.
24
 */
25
namespace Haridarshan\Instagram;
26
27
use Haridarshan\Instagram\Exceptions\InstagramOAuthException;
28
use stdClass;
29
30
/**
31
 * Instagram Oauth class
32
 *
33
 * @library			instagram-php
34
 *
35
 * @license 		https://opensource.org/licenses/MIT MIT
36
 *
37
 * @link			http://github.com/haridarshan/instagram-php Class Documentation
38
 * @link			http://instagram.com/developer/ API Documentation
39
 *
40
 * @author			Haridarshan Gorana 	<[email protected]>
41
 *
42
 * @since			May 09, 2016
43
 *
44
 * @copyright		Haridarshan Gorana
45
 *
46
 * @version			2.2.2
47
 */
48
class InstagramOAuth
49
{
50
    /** @var string $accessToken */
51
    protected $accessToken;
52
53
    /** @var object $user */
54
    protected $user;
55
56
    /**
57
     * InstagramOAuth Entity
58
     *
59
     * @param stdClass $oauth
60
     *
61
     * @throws InstagramOAuthException
62
     */
63
    public function __construct(stdClass $oauth)
64
    {
65
        if (empty($oauth)) {
66
            throw new InstagramOAuthException('Bad Request 400 empty Response', 400);
67
        }
68
69
        $this->accessToken = $oauth->access_token;
70
        $this->user = isset($oauth->user) ? $oauth->user : null;
71
    }
72
73
    /**
74
     * Get Access Token
75
     *
76
     * @return string
77
     */
78
    public function getAccessToken()
79
    {
80
        return $this->accessToken;
81
    }
82
83
    /**
84
     * Set Access Token
85
     *
86
     * @param string $token
87
     */
88
    public function setAccessToken($token)
89
    {
90
        $this->accessToken = $token;
91
    }
92
93
    /**
94
     * If AccessToken is set return true else false
95
     *
96
     * @return bool
97
     */
98
    public function isAccessTokenSet()
99
    {
100
        return isset($this->accessToken);
101
    }
102
103
    /**
104
     * Get User Info
105
     *
106
     * @return object
107
     */
108
    public function getUserInfo()
109
    {
110
        return $this->user;
111
    }
112
}
113