Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
InvalidTransitionException
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 between
100.00% covered (success)
100.00%
7 / 7
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\StateMachine;
20
21use DomainException;
22use UnitEnum;
23
24 class InvalidTransitionException extends DomainException
25{
26    /**
27     * @param UnitEnum $from
28     * @param UnitEnum $to
29     *
30     * @return self
31     */
32    public static function between(UnitEnum $from, UnitEnum $to): self
33    {
34        return new self(\sprintf(
35            'Invalid transition from %s::%s to %s::%s.',
36            $from::class,
37            $from->name,
38            $to::class,
39            $to->name,
40        ));
41    }
42}