Completed
Push — master ( 483eda...cb59ac )
by Дмитрий
03:04
created

AbstractBaseProvider   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 116
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Importance

Changes 0
Metric Value
wmc 10
c 0
b 0
f 0
lcom 3
cbo 1
dl 0
loc 116
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getRedirectUri() 0 4 1
A getRedirectUrl() 0 4 1
getBaseUri() 0 1 ?
getName() 0 1 ?
A getScope() 0 4 1
A setScope() 0 4 1
A getScopeInline() 0 4 1
A getFields() 0 4 1
A setFields() 0 4 1
A getFieldsInline() 0 4 1
A getConsumer() 0 4 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
abstract class AbstractBaseProvider
10
{
11
    /**
12
     * @var Service
13
     */
14
    public $service;
15
16
    /**
17
     * @var Consumer
18
     */
19
    protected $consumer;
20
21
    /**
22
     * @var array
23
     */
24
    protected $scope = array();
25
26
    /**
27
     * @var array
28
     */
29
    protected $fields = array();
30
31
    /**
32
     * @param Service $service
33
     * @param Consumer $consumer
34
     */
35
    public function __construct(Service $service, Consumer $consumer)
36
    {
37
        $this->service = $service;
38
        $this->consumer = $consumer;
39
    }
40
41
    /**
42
     * @return mixed
43
     */
44
    protected function getRedirectUri()
45
    {
46
        return $this->service->getConfig()['redirectUri'];
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getRedirectUrl()
53
    {
54
        return $this->getRedirectUri() . '/' . $this->getName() . '/';
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    abstract public function getBaseUri();
61
62
    /**
63
     * Return Provider's name
64
     *
65
     * @return string
66
     */
67
    abstract public function getName();
68
69
    /**
70
     * @return array
71
     */
72
    public function getScope()
73
    {
74
        return $this->scope;
75
    }
76
77
    /**
78
     * @param array $scope
79
     */
80
    public function setScope(array $scope)
81
    {
82
        $this->scope = $scope;
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getScopeInline()
89
    {
90
        return implode(',', $this->scope);
91
    }
92
93
    /**
94
     * @return array
95
     */
96
    public function getFields()
97
    {
98
        return $this->fields;
99
    }
100
101
    /**
102
     * @param array $fields
103
     */
104
    public function setFields(array $fields)
105
    {
106
        $this->fields = $fields;
107
    }
108
109
    /**
110
     * @return string
111
     */
112
    public function getFieldsInline()
113
    {
114
        return implode(',', $this->fields);
115
    }
116
117
    /**
118
     * @return \SocialConnect\Auth\Consumer
119
     */
120
    public function getConsumer()
121
    {
122
        return $this->consumer;
123
    }
124
}
125