1 | <?php |
||
43 | class Client extends BaseModel implements ClientModelInterface |
||
44 | { |
||
45 | /** |
||
46 | * @inheritdoc |
||
47 | */ |
||
48 | public function behaviors() |
||
49 | 25 | { |
|
50 | $behaviors = parent::behaviors(); |
||
51 | 25 | $behaviors['emptyArray'] = [ |
|
52 | 25 | 'class' => EmptyArrayBehavior::class, |
|
53 | 25 | 'attributes' => ['scopes', 'grantTypes'], |
|
54 | 25 | ]; |
|
55 | $behaviors['splitToArray'] = [ |
||
56 | 25 | 'class' => SplitToArrayBehavior::class, |
|
57 | 25 | 'attributes' => ['redirectUri'], |
|
58 | 25 | ]; |
|
59 | return $behaviors; |
||
60 | 25 | } |
|
61 | |||
62 | /** |
||
63 | * @inheritdoc |
||
64 | */ |
||
65 | public function rules() |
||
66 | 21 | { |
|
67 | return [ |
||
68 | [['id', 'secret', 'name'], 'string'], |
||
69 | 21 | [['redirectUri'], function($attribute, $params) { |
|
|
|||
70 | 21 | $data = $this->{$attribute}; |
|
71 | 4 | ||
72 | if (is_array($data) === false) { |
||
73 | 4 | $data = explode(' ', $data); |
|
74 | 3 | } |
|
75 | 3 | foreach($data as $redirectUri) { |
|
76 | 4 | $isLocalhost = strncmp('http://localhost', $redirectUri, 16); |
|
77 | 4 | $isSecureLocalhost = strncmp('https://localhost', $redirectUri, 17); |
|
78 | 4 | if (($isLocalhost !== 0) && ($isSecureLocalhost !== 0)) { |
|
79 | 4 | $validator = new UrlValidator(); |
|
80 | 4 | if ($validator->validate($redirectUri, $error) === false) { |
|
81 | 4 | $this->addError($attribute, $error); |
|
82 | 1 | break; |
|
83 | 1 | } |
|
84 | } |
||
85 | 4 | } |
|
86 | 4 | }], |
|
87 | 21 | [['scopes'], 'scope'], |
|
88 | 21 | [['isPublic'], 'boolean', 'trueValue' => true, 'falseValue' => false, 'strict' => true], |
|
89 | 21 | [['id', 'secret', 'isPublic'], 'required'], |
|
90 | 21 | ]; |
|
91 | 21 | } |
|
92 | |||
93 | /** |
||
94 | * @return \sweelix\oauth2\server\interfaces\ClientServiceInterface |
||
95 | * @throws \yii\base\InvalidConfigException |
||
96 | */ |
||
97 | 25 | protected static function getDataService() |
|
101 | |||
102 | /** |
||
103 | * @inheritdoc |
||
104 | */ |
||
105 | 21 | public function key() |
|
109 | |||
110 | /** |
||
111 | * @return array definition of model attributes |
||
112 | * @since 1.0.0 |
||
113 | */ |
||
114 | 21 | public function attributesDefinition() |
|
127 | |||
128 | /** |
||
129 | * @inheritdoc |
||
130 | */ |
||
131 | 22 | public static function findOne($id) |
|
135 | |||
136 | /** |
||
137 | * @inheritdoc |
||
138 | */ |
||
139 | 21 | public function save($runValidation = true, $attributes = null) |
|
149 | |||
150 | /** |
||
151 | * @inheritdoc |
||
152 | */ |
||
153 | 1 | public function delete() |
|
157 | |||
158 | /** |
||
159 | * @inheritdoc |
||
160 | */ |
||
161 | 5 | public function hasUser($userId) |
|
165 | |||
166 | /** |
||
167 | * @inheritdoc |
||
168 | */ |
||
169 | 3 | public function addUser($userId) |
|
173 | |||
174 | /** |
||
175 | * @inheritdoc |
||
176 | */ |
||
177 | 4 | public function removeUser($userId) |
|
181 | |||
182 | /** |
||
183 | * @inheritdoc |
||
184 | */ |
||
185 | 1 | public static function findAllByUserId($userId) |
|
189 | |||
190 | /** |
||
191 | * @inheritdoc |
||
192 | */ |
||
193 | public static function findAll() |
||
197 | } |
||
198 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.