Completed
Push — master ( 3f7868...fe95db )
by Дмитрий
03:54
created

getAccessTokenByRequestParameters()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
1
<?php
2
/**
3
 * SocialConnect project
4
 * @author: Patsura Dmitry https://github.com/ovr <[email protected]>
5
 */
6
7
namespace SocialConnect\Auth;
8
9
use SocialConnect\Auth\AccessTokenInterface;
10
11
abstract class AbstractBaseProvider
12
{
13
    /**
14
     * @var Service
15
     */
16
    public $service;
17
18
    /**
19
     * @var Consumer
20
     */
21
    protected $consumer;
22
23
    /**
24
     * @var array
25
     */
26
    protected $scope = array();
27
28
    /**
29
     * @var array
30
     */
31
    protected $fields = array();
32
33
    /**
34
     * @param Service $service
35
     * @param Consumer $consumer
36
     */
37 6
    public function __construct(Service $service, Consumer $consumer)
38
    {
39 6
        $this->service = $service;
40 6
        $this->consumer = $consumer;
41 6
    }
42
43
    /**
44
     * @return mixed
45
     */
46
    protected function getRedirectUri()
47
    {
48
        return $this->service->getConfig()['redirectUri'];
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getRedirectUrl()
55
    {
56
        return $this->getRedirectUri() . '/' . $this->getName() . '/';
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    abstract public function getBaseUri();
63
64
    /**
65
     * Return Provider's name
66
     *
67
     * @return string
68
     */
69
    abstract public function getName();
70
71
    /**
72
     * @param array $requestParameters
73
     * @return \SocialConnect\Auth\AccessTokenInterface
74
     */
75
    abstract public function getAccessTokenByRequestParameters(array $requestParameters);
76
77
    /**
78
     * @return string
79
     */
80
    abstract public function makeAuthUrl();
81
82
    /**
83
     * Get current user identity from social network by $accessToken
84
     *
85
     * @param AccessTokenInterface $accessToken
86
     * @return \SocialConnect\Common\Entity\User
87
     *
88
     * @throws \SocialConnect\Auth\Provider\Exception\InvalidResponse
89
     */
90
    abstract public function getIdentity(AccessTokenInterface $accessToken);
91
92
    /**
93
     * @return array
94
     */
95
    public function getScope()
96
    {
97
        return $this->scope;
98
    }
99
100
    /**
101
     * @param array $scope
102
     */
103
    public function setScope(array $scope)
104
    {
105
        $this->scope = $scope;
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getScopeInline()
112
    {
113
        return implode(',', $this->scope);
114
    }
115
116
    /**
117
     * @return array
118
     */
119
    public function getFields()
120
    {
121
        return $this->fields;
122
    }
123
124
    /**
125
     * @param array $fields
126
     */
127
    public function setFields(array $fields)
128
    {
129
        $this->fields = $fields;
130
    }
131
132
    /**
133
     * @return string
134
     */
135
    public function getFieldsInline()
136
    {
137
        return implode(',', $this->fields);
138
    }
139
140
    /**
141
     * @return \SocialConnect\Auth\Consumer
142
     */
143 1
    public function getConsumer()
144
    {
145 1
        return $this->consumer;
146
    }
147
}
148