Profile   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 17
c 1
b 0
f 0
dl 0
loc 69
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A profile() 0 5 1
A getEditUrl() 0 7 1
A __construct() 0 23 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Admin\Http\Controllers\Admin\Form;
6
7
use AbterPhp\Admin\Constant\Route;
8
use AbterPhp\Admin\Form\Factory\Profile as FormFactory;
9
use AbterPhp\Admin\Orm\UserRepo as Repo;
10
use AbterPhp\Framework\Assets\AssetManager;
11
use AbterPhp\Framework\Constant\Session;
12
use AbterPhp\Framework\I18n\ITranslator;
13
use AbterPhp\Framework\Session\FlashService;
14
use Casbin\Exceptions\CasbinException;
15
use Opulence\Events\Dispatchers\IEventDispatcher;
16
use Opulence\Routing\Urls\UrlException;
17
use Opulence\Routing\Urls\UrlGenerator;
18
use Opulence\Sessions\ISession;
19
use Psr\Log\LoggerInterface;
20
use Throwable;
21
22
/**
23
 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
24
 */
25
class Profile extends User
26
{
27
    /**
28
     * Profile constructor.
29
     *
30
     * @param FlashService     $flashService
31
     * @param LoggerInterface  $logger
32
     * @param ITranslator      $translator
33
     * @param UrlGenerator     $urlGenerator
34
     * @param Repo             $repo
35
     * @param ISession         $session
36
     * @param FormFactory      $formFactory
37
     * @param IEventDispatcher $eventDispatcher
38
     * @param AssetManager     $assetManager
39
     * @param string           $frontendSalt
40
     */
41
    public function __construct(
42
        FlashService $flashService,
43
        LoggerInterface $logger,
44
        ITranslator $translator,
45
        UrlGenerator $urlGenerator,
46
        Repo $repo,
47
        ISession $session,
48
        FormFactory $formFactory,
49
        IEventDispatcher $eventDispatcher,
50
        AssetManager $assetManager,
51
        string $frontendSalt
52
    ) {
53
        parent::__construct(
54
            $flashService,
55
            $logger,
56
            $translator,
57
            $urlGenerator,
58
            $repo,
59
            $session,
60
            $formFactory,
61
            $eventDispatcher,
62
            $assetManager,
63
            $frontendSalt
64
        );
65
    }
66
67
    /**
68
     * @throws Throwable
69
     * @throws CasbinException
70
     * @throws URLException
71
     */
72
    public function profile()
73
    {
74
        $userId = (string)$this->session->get(Session::USER_ID);
75
76
        $this->edit($userId);
77
    }
78
79
    /**
80
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
81
     *
82
     * @param string $id
83
     *
84
     * @return string
85
     * @throws \Opulence\Routing\Urls\URLException
86
     */
87
    protected function getEditUrl(string $id): string
88
    {
89
        $urlGenerator = $this->urlGenerator;
90
91
        $url = $urlGenerator->createFromName(Route::PROFILE_EDIT);
92
93
        return $url;
94
    }
95
}
96