Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
DispatchMode
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
5
100.00% covered (success)
100.00%
1 / 1
 description
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 isSync
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isAsync
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/**
6 * Ergonomic utilities for PHP enums, including names, values, lookups, and option maps.
7 *
8 * This file is part of fast-forward/enum project.
9 *
10 * @author   Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
11 * @license  https://opensource.org/licenses/MIT MIT License
12 *
13 * @see      https://github.com/php-fast-forward/enum
14 * @see      https://github.com/php-fast-forward/enum/issues
15 * @see      https://php-fast-forward.github.io/enum/
16 * @see      https://datatracker.ietf.org/doc/html/rfc2119
17 */
18
19namespace FastForward\Enum\Event;
20
21use FastForward\Enum\DescribedEnumInterface;
22use FastForward\Enum\LabeledEnumInterface;
23use FastForward\Enum\Trait\Comparable;
24use FastForward\Enum\Trait\HasLabel;
25use FastForward\Enum\Trait\HasNameLookup;
26use FastForward\Enum\Trait\HasNameMap;
27use FastForward\Enum\Trait\HasNames;
28use FastForward\Enum\Trait\HasOptions;
29use FastForward\Enum\Trait\HasValueMap;
30use FastForward\Enum\Trait\HasValues;
31
32enum DispatchMode: string implements DescribedEnumInterface, LabeledEnumInterface
33{
34    use Comparable;
35    use HasLabel;
36    use HasNameLookup;
37    use HasNameMap;
38    use HasNames;
39    use HasOptions;
40    use HasValueMap;
41    use HasValues;
42
43    case Sync = 'sync';
44    case Async = 'async';
45
46    /**
47     * @return string
48     */
49    public function description(): string
50    {
51        return match ($this) {
52            self::Sync => 'Dispatches listeners immediately within the current execution flow.',
53            self::Async => 'Dispatches listeners through a deferred or queued execution path.',
54        };
55    }
56
57    /**
58     * @return bool
59     */
60    public function isSync(): bool
61    {
62        return $this->is(self::Sync);
63    }
64
65    /**
66     * @return bool
67     */
68    public function isAsync(): bool
69    {
70        return $this->is(self::Async);
71    }
72}