Passed
Pull Request — master (#72)
by Daniel
06:31
created

VerifyEmailAddressAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 18
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 9 2
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 VerifyEmailAddressAction
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->verifyEmailAddress($username, $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