Logout::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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