GetUserAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A __invoke() 0 10 1
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.io and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusVueStorefrontPlugin\Controller\User;
14
15
use BitBag\SyliusVueStorefrontPlugin\Factory\GenericSuccessViewFactoryInterface;
16
use BitBag\SyliusVueStorefrontPlugin\Factory\User\UserProfileViewFactoryInterface;
17
use BitBag\SyliusVueStorefrontPlugin\Sylius\Provider\LoggedInShopUserProviderInterface;
18
use FOS\RestBundle\View\View;
19
use FOS\RestBundle\View\ViewHandlerInterface;
20
use Symfony\Component\HttpFoundation\Request;
21
use Symfony\Component\HttpFoundation\Response;
22
23
final class GetUserAction
24
{
25
    /** @var LoggedInShopUserProviderInterface */
26
    private $loggedInShopUserProvider;
27
28
    /** @var ViewHandlerInterface */
29
    private $viewHandler;
30
31
    /** @var GenericSuccessViewFactoryInterface */
32
    private $genericSuccessViewFactory;
33
34
    /** @var UserProfileViewFactoryInterface */
35
    private $userProfileViewFactory;
36
37
    public function __construct(
38
        LoggedInShopUserProviderInterface $loggedInShopUserProvider,
39
        ViewHandlerInterface $viewHandler,
40
        GenericSuccessViewFactoryInterface $genericSuccessViewFactory,
41
        UserProfileViewFactoryInterface $userProfileViewFactory
42
    ) {
43
        $this->loggedInShopUserProvider = $loggedInShopUserProvider;
44
        $this->viewHandler = $viewHandler;
45
        $this->genericSuccessViewFactory = $genericSuccessViewFactory;
46
        $this->userProfileViewFactory = $userProfileViewFactory;
47
    }
48
49
    public function __invoke(Request $request): Response
50
    {
51
        $user = $this->loggedInShopUserProvider->provide()->getCustomer();
52
53
        return $this->viewHandler->handle(View::create(
54
            $this->genericSuccessViewFactory->create(
55
                $this->userProfileViewFactory->create($user)),
56
            Response::HTTP_OK)
57
        );
58
    }
59
}
60