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

VerifyEmailAddressAction::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 3
dl 0
loc 11
rs 10
c 0
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\Exception\UnexpectedValueException;
18
use Silverback\ApiComponentsBundle\Helper\User\EmailAddressManager;
19
use Symfony\Component\HttpFoundation\Response;
20
21
/**
22
 * @author Daniel West <[email protected]>
23
 */
24
class VerifyEmailAddressAction
25
{
26
    private EmailAddressManager $emailAddressManager;
27
28
    public function __construct(EmailAddressManager $emailAddressManager)
29
    {
30
        $this->emailAddressManager = $emailAddressManager;
31
    }
32
33
    public function __invoke(string $username, string $emailAddress, string $token): Response
34
    {
35
        try {
36
            $this->emailAddressManager->verifyEmailAddress($username, $token);
37
        } catch (InvalidArgumentException $exception) {
38
            return new Response(null, Response::HTTP_NOT_FOUND);
39
        } catch (UnexpectedValueException $exception) {
40
            return new Response(null, Response::HTTP_UNAUTHORIZED);
41
        }
42
43
        return new Response(null, Response::HTTP_OK);
44
    }
45
}
46