Passed
Push — v5 ( c0775f...b45ef7 )
by Alexey
16:22
created

SocialAppController::authAction()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 4
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Social app controller
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2015 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
12
namespace Inji\Users;
13
use Inji\Controller;
14
15
class SocialAppController extends Controller {
16
17
    public function authAction($socialCode = '') {
18
        if (!$socialCode) {
19
            Tools::redirect('/', 'Не указана соц сеть');
0 ignored issues
show
Bug introduced by
The type Inji\Users\Tools was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
        }
21
        $social = Users\Social::get($socialCode, 'code');
0 ignored issues
show
Bug introduced by
The type Inji\Users\Users\Social was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
        if (!$social) {
23
            Tools::redirect('/', 'Такой соц. сети не найдено');
24
        }
25
        $helper = 'Users\SocialHelper\\' . $social->object_name;
26
        $helper::auth();
27
    }
28
29
    public function disconnectAction($socialCode = '') {
30
        if (!$socialCode) {
31
            Tools::redirect('/', 'Не указана соц сеть');
32
        }
33
        $social = Users\Social::get($socialCode, 'code');
34
        if (!$social) {
35
            Tools::redirect('/', 'Такой соц. сети не найдено');
36
        }
37
        foreach (\Users\User::$cur->socials as $userSocial) {
38
            if ($userSocial->social_id == $social->id) {
39
                $userSocial->delete();
40
                Tools::redirect('/', 'Связь с соц. сетью ' . $social->name . ' была удалена');
41
            }
42
        }
43
        Tools::redirect('/', 'Связь с соц. сетью ' . $social->name . ' не найдена');
44
    }
45
46
}
47