Code

< 40 %
40-60 %
> 60 %
1
<?php
2
3
/**
4
 * Part of SplTypes package.
5
 *
6
 * (c) Adrien Loyant <[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 Ducks\Component\SplTypes;
15
16
/**
17
 * SplStringEnum gives the ability to emulate and create int enumeration objects natively in PHP.
18
 *
19
 * @extends SplEnumBacked<string>
20
 *
21
 * @psalm-api
22
 */
23
abstract class SplStringEnum extends SplEnumBacked
24
{
25
    /**
26
     * Value of enum instance.
27
     *
28
     * @var string
29
     */
30
    protected string $value;
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    final protected function __construct()
36
    {
37
        $this->__default = '';
38
39
        parent::__construct();
40
    }
41
42
    /**
43
     * Method called when a script tries to call an object as a function.
44
     *
45
     * @return string
46
     *
47
     * @psalm-suppress MixedInferredReturnType
48
     */
49
    final public function &__invoke(): string
50
    {
51
        return $this->__default;
52
    }
53
}
54