Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
CommentFilterScope
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
0.00% covered (danger)
0.00%
0 / 1
 fromValue
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\Comments\Domain\Model;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * Filter scope for comments stream.
13 *
14 * @package App\Modules\Comments\Domain\Model
15 */
16enum CommentFilterScope: string
17{
18    case ALL = 'all';
19    case MINE = 'mine';
20    case PINNED = 'pinned';
21    case VERIFIED = 'verified';
22
23    /**
24     * Resolves scope from raw input value with fallback to ALL.
25     *
26     * @param string|null $value Raw string scope.
27     * @return self Resolved scope.
28     */
29    public static function fromValue(?string $value): self
30    {
31        if ($value === null || $value === '') {
32            return self::ALL;
33        }
34
35        return self::tryFrom(strtolower(trim($value))) ?? self::ALL;
36    }
37}