Logout   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Field\Mutation;
6
7
use Application\Model\User;
8
use Ecodev\Felix\Api\Field\FieldInterface;
9
use GraphQL\Type\Definition\Type;
10
use Mezzio\Session\SessionInterface;
11
12
abstract class Logout implements FieldInterface
13
{
14 1
    public static function build(): iterable
15
    {
16 1
        yield 'logout' => fn () => [
17 1
            'type' => Type::nonNull(Type::boolean()),
18 1
            'description' => 'Log out a user',
19 1
            'resolve' => function ($root, array $args, SessionInterface $session): bool {
20
                // Logout
21 1
                $session->clear();
22 1
                User::setCurrent(null);
23
24 1
                return true;
25 1
            },
26 1
        ];
27
    }
28
}
29