Test Failed
Pull Request — master (#72)
by Daniel
06:07
created

EmailAddressConfirmAction::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 3
dl 0
loc 9
rs 10
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components Bundle Project
5
 *
6
 * (c) Daniel West <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentsBundle\Action\User;
15
16
use Silverback\ApiComponentsBundle\Exception\InvalidArgumentException;
17
use Silverback\ApiComponentsBundle\Helper\User\EmailAddressManager;
18
use Symfony\Component\HttpFoundation\Response;
19
20
/**
21
 * @author Daniel West <[email protected]>
22
 */
23
class EmailAddressConfirmAction
24
{
25
    private EmailAddressManager $emailAddressManager;
26
27
    public function __construct(EmailAddressManager $emailAddressManager)
28
    {
29
        $this->emailAddressManager = $emailAddressManager;
30
    }
31
32
    public function __invoke(string $username, string $emailAddress, string $token): Response
33
    {
34
        try {
35
            $this->emailAddressManager->confirmNewEmailAddress($username, $emailAddress, $token);
36
        } catch (InvalidArgumentException $exception) {
37
            return new Response(null, Response::HTTP_NOT_FOUND);
38
        }
39
40
        return new Response(null, Response::HTTP_OK);
41
    }
42
}
43